3 ms·
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 th
by rowanG077 3mo 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)
}