Avoid checking if error is nil repetition?
I'm currently learning go and some of my code looks like this:
a, err := doA()
if err != nil {
return nil, err
}
b, err := doB(a)
if err != nil {
return nil, err
}
c, err := doC(c)
if err != nil {
return nil, err
}
... and so on ...
This looks kinda wrong to me because the error checking takes most of the
lines. Is there a better way to do error handling? Can I maybe avoid this
with some refactoring?
No comments:
Post a Comment