In Go errors can be returned from a function call. The convention is that if a method can fail, the last returned argument is an error.
func DoAndReturnSomething() (string, error) {
if os.Getenv("ERROR") == "1" {
return "", errors.New("The method fai...