pkg/errors
View on GitHub ↗ ★ 8,257 Go
Simple error handling primitives
56 mentions on Hacker News by 49 people: 1 story, 55 comments · first 2016-05-02 · latest 2025-06-03
20082026
-
There's already a good library like that: https://github.com/pkg/errors It is API-compatible with the errors package, and you get errors.Wrap(err, message), errors.Wrapf(err, message, args) and errors.Cause(err).
comment by lobster_johnson · 2017-01-18 · in My Go Resolutions for 2017 -
Yup, my solution as well. As well as a couple other common libraries (eg: https://github.com/pkg/errors ) The only downside to this is you can no longer treat errors as values. Eg, you can't do: err := Func() if err == ErrBadThing { // do…
comment by notheguyouthink · 2017-01-18 · in My Go Resolutions for 2017 -
There are cases where it makes sense, like https://github.com/pkg/errors which is meant to be a drop-in replacement for the stdlib `errors` package containing a superset of its functionality.
comment by insertnickname · 2016-12-06 · in Mux – A lightweight, fast HTTP request router for Go -
In Go, I use https://github.com/pkg/errors these days and wrap errors with stack trace. package main import ( "fmt" "io" "os" "github.com/pkg/errors" ) func main() { v, err := run() if err != nil { fmt.Printf("err=%+v\n", err) os.Exit(1) }…
comment by hnakamur · 2016-11-11 · in Announcing Rust 1.13 -
> having no stack for errors is insanely frustrating. Check out https://github.com/pkg/errors If you want more rich control of the output of the stack trace there's https://github.com/go-stack/stack
comment by jud_white · 2016-05-02 · in Go best practices, six years in