go-proverbs | Rob Pike gave a talk
kandi X-RAY | go-proverbs Summary
kandi X-RAY | go-proverbs Summary
In 2015, Rob Pike (one of Go's creators) gave a talk at Gopherfest SV 2015 where he outlined what have become known as "Go Proverbs", a set of principles that every Go developer should keep in mind when working with the programming language. This package simply exposes those proverbs and their relevant locations in the talk video.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Initialize Proverb data .
- Nth returns the nthProverb with nth .
- All returns all Proverbose verbs
- Random returns a Proverb .
- Error implements error interface
go-proverbs Key Features
go-proverbs Examples and Code Snippets
package main
import "github.com/jboursiquot/go-proverbs"
func main() {
list, err := proverbs.All()
if err != nil {
fmt.Println(err)
}
for _, p := range list {
fmt.Printf("%+v\n", p)
}
}
&{Saying:The bigger the interface, the
package main
import "github.com/jboursiquot/go-proverbs"
func main() {
p, err := proverbs.Nth(4)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", p)
}
&{Saying:Make the zero value useful. Link:https://www.youtube.com/watch?v=
package main
import "github.com/jboursiquot/go-proverbs"
func main() {
fmt.Println(proverbs.Random())
fmt.Println(proverbs.Random())
fmt.Println(proverbs.Random())
}
&{With the unsafe package there are no guarantees. https://www.youtube.
Community Discussions
Trending Discussions on go-proverbs
QUESTION
I've recently watch this talk by Liz Rice (which I highly recommend!), and I've seen that instead of writing:
...ANSWER
Answered 2021-Mar-01 at 07:46The MustXXX(error)
pattern is useful when the error
could arise at runtime, but whether it does is actually decided at compile time. Meaning if the source code is what it should be, the error will not happen at runtime.
Shining examples are template.Must()
and regexp.MustCompile()
. If you provide a valid template or valid regexp in the source code, parsing them will never fail at runtime. In these situations using Must()
results in shorter and clear code. Tests should be supplied to detect if invalid template or regexp is used in the source, so the mistake is detected early (when tests are run).
Other than that (when an error could happen based on runtime conditions like user input, data read from external source etc.), the Must()
pattern is obviously not advised and you should handle the error properly.
See related: Multiple values in single-value context
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install go-proverbs
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page