Hacker GitHub

← All repos

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

Mentions per year 56 mentions · busiest year 2019 (13)
20082026
  1. There was a proposal at some point to integrate github.com/pkg/errors into the stdlib, since it's pretty much a drop-in replacement to the current errors package, with extras. One of them is that errors contain stack traces that can be…
    comment by saturn_vk · 2017-01-18 · in My Go Resolutions for 2017
  2. 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
  3. 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
  4. 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.
  5. 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
  6. > 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