Source: https://www.youtube.com/watch?v=1B71SL6Y0kA&t=718s
Author: John Cinnamond
Go code is full of variations of
1if err != nil {
2 return err
3}
which affects the readability of code
1val, err := doThing()
2if err != nil {
3 return err
4}
5
6bar, err := foo(val)
7if err != nil {
8 return err
9}
lift or abstract error
1func signupHandler(w http.ResponseWriter, r *http.Request) {
2 s := newSignupRequest(w,r)
3 s.validate()
4 s.checkNewRegistration()
5 s.register()
6 s.sellEmailToRecruiter()
7 s.log()
8 s.response()
9}
don't actually do this, but its encouraging you to think about the shape of your code. Use types to make the shapes simpler, to cope with complex code.