In Go returning an error implies that the caller will need to add 3 lines of the source for each call to propagate the error. This is really ugly. Rust managed to reduce that source overhead down to the single extra ? character while keeping all the benefits of explicit error handling. I wish Go gets something similar.
Being explicit is a double edge sword. It requires more typing, but there's also no don't about what the code is doing.
Whether the bit of source is a single character or a paragraph of prose is about verbosity rather than explicitness as long as the behaviour under discussion is caused by a piece of source with precisely that purpose.
if f, err := os.Open(path); err != nil {
return nil, fmt.Errorf("could not open path: %v", err)
}
This is the vast majority of my error management code in go. Is rust less verbose in this regard? AFAIK, the question mark operator is equivalent to `if err != nil { return nil, err }`.1. Define a conversion between the two errors that adds the context.
2. Use .map_err() at the callsite to do the transformation there.
Evolution of Go (Griesemer, GopherCon 2015)
Video: https://www.youtube.com/watch?v=0ReKdcpNyQg
Slides: https://talks.golang.org/2015/gophercon-goevolution.slide
Origins of Go Concurrency (Rob Pike, OSCON 2010)
Video: https://www.youtube.com/watch?v=3DtUzH3zoFo
Slides: http://go-lang.cat-v.org/talks/slides/emerging-languages-cam...