To be clear: The recommendation is *not* to compare strings. The recommendation is to compare errors by identity and not consider errors created by different packages to be equal.
If you desperately need your error to be considered "the same" as another, the most correct way would be to implement `Is(other error) bool`, e.g.
type notQuiteEOF struct {}
func (notQuiteEOF) Error() string {
return "not quite EOF, but almost"
}
func (notQuiteEOF) Is(other error) bool {
return other == io.EOF
}
This allows errors to be considered "the same" under `errors.Is`, while not actually being the same and it's probably the recommended mechanism to "imitate" an error from a different package.