[Solved] Do all Go functions return err as second return value?


Answering your question:
Fortunately, Go prevents certain types of programmers errors. It just won’t let you compile the program if you forget one of the values that the function returns.

It’s a good practice to return errors in Go, read Errors section of Effective Go

Library routines must often return some sort of error indication to the caller. As mentioned earlier, Go’s multivalue return makes it easy to return a detailed error description alongside the normal return value. It is good style to use this feature to provide detailed error information.

and Error handling and Go

In Go, error handling is important. The language’s design and conventions encourage you to explicitly check for errors where they occur

However there is a problem described here and probably will be improved in Go 2

In general Go programs have too much code checking errors and not enough code handling them.

Dave Cheney writes in the blog

I’m suggesting changing your code so you don’t have as many errors to handle.

0

solved Do all Go functions return err as second return value?