Sindre Myren
1 min readJun 10, 2020

--

Yes. Relying on fmt.Errorf and %w appear to be a more practical pattern when you don’t need to be able to match both the “inner” and “outer” type, which usually you don’t.

Also not sure the Is implementation is really to relevant. Nowadays, I would probably write a const string-based error with only an Error function, and rely on fmt.Errorf like you describe.

package mypkgtype strError stringfunc (err strError) Error() string {
return string(err)
}
const (
ErrFoo = strError("foo")
)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Sindre Myren
Sindre Myren

Written by Sindre Myren

Backend developer at Searis AS, and occasional tech blogger.

No responses yet

Write a response