On Friday 10 May 2024 at 17:03:46 UTC+1 Sebastian Bogan wrote: 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") If you compare an error value against this constant, and the error value has the correct type, then you're actually doing a character-by-character comparison of the string text, not unique object identity. https://go.dev/play/p/rNlZEf0qZfI -- 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/7cafdb37-9e29-4ab5-8bab-49d7b9fc59fcn%40googlegroups.com.