3 ms·
> 1) Syntactic sugar for if err != nil { return err }; similar to ? in Rust IMO they could exactly use what you wrote, ie. change gofmt to have it all on one l
by eikenberry 4y ago
> 1) Syntactic sugar for if err != nil { return err }; similar to ? in Rust
IMO they could exactly use what you wrote, ie. change gofmt to have it all on one line like that. The biggest annoyance with the error return boilerplate is the waste of vertical space and just squashing it into 1 line would fix that.
- metaltyphoon 4y agoOr perhaps allow variable assignment to be used in the same scope. if x, err := someMethod(); err != nil { return err } x <- is usable here.