|
|
|
|
|
by rowanG077
2 days ago
|
|
Are you really being so obtuse? Of course in real code you might use the error. For printing, forwarding it to a logging frame or anything else. The point is the error does not guard access to the return value. Here basically the same example: package main import (
"errors"
"fmt"
) func getMessage() (string, error) {
return "DO NOT INSPECT", errors.New("something went wrong")
} func main() {
msg, err := getMessage()
fmt.Println(msg)
fmt.Println(err)
} |
|