Hello Everyone, I was wondering, what was / is the reason for exposing errors as public vars - rather than constants? Doesn't that impose some risk?
For example: fs.ErrNotExist = errors.New("foo") _, err = os.ReadFile("./invalid") if !errors.Is(err, fs.ErrNotExist) { fmt.Println("is NOT fs.ErrNotExist") } Would something like the following work (and be less risky)?: type ConstError string func (e ConstError) Error() string { return string(e) } const ErrNotExist = ConstError("file does not exist") Thanks Seb -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/45805816-9264-4312-a524-3fba6e3a77d2n%40googlegroups.com.