Closed
Description
if you are using a lot of functions that return an error value, one mistake you might make is this:
val1, err := someFunc()
if err != nil {
return err
}
someStruct.someField, err = someOtherFunc()
someOtherStruct.someField, err = Func3()
if err != nil {
return err
}
It may look simple in the example, but if you have a bunch of loops and if statements, it could be much harder to see, e.g.
// ...
for someCondition {
strct.Field, err = GetFoo()
}
if err != nil {
return err
}
This will catch an error if it is the last call is an error, but will let it past otherwise. It is also hard to track down as you don't know what you're looking for, or where you're looking for it, as the function will likely continue running but produce no output, or segfault due to derefrencing a nil pointer (that was supposed to be set by a function that returned an error).
this is worsened by #337.