Skip to content

go-faster/errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d4170b7 · Nov 6, 2021

History

70 Commits
Nov 5, 2021
Nov 6, 2021
Nov 3, 2021
Nov 3, 2021
Nov 3, 2021
Nov 3, 2021
Nov 4, 2021
Nov 3, 2021
Jan 25, 2019
Nov 6, 2021
Nov 3, 2021
Nov 3, 2021
Nov 3, 2021
Nov 3, 2021
Nov 6, 2021
Nov 6, 2021
Nov 6, 2021
Nov 3, 2021
Nov 5, 2021
Nov 6, 2021
Nov 3, 2021
Nov 3, 2021
Nov 6, 2021
Nov 3, 2021
Nov 5, 2021
Nov 5, 2021
Nov 3, 2021
Nov 6, 2021

Repository files navigation

errors Go Reference codecov

Fork of xerrors with explicit Wrap instead of %w.

Clear is better than clever.

go get github.com/go-faster/errors
if err != nil {
	return errors.Wrap(err, "something went wrong")
}

Why

  • Using Wrap is the most explicit way to wrap errors
  • Wrapping with fmt.Errorf("foo: %w", err) is implicit, redundant and error-prone
  • Parsing "foo: %w" is implicit, redundant and slow
  • The pkg/errors and xerrrors are not maintainted
  • The cockroachdb/errors is too big
  • The errors has no caller stack trace

Don't need traces?

Call errors.DisableTrace or use build tag noerrtrace.

Migration

go get github.com/go-faster/errors/cmd/gowrapper@latest
gowrapper ./...

License

BSD-3-Clause, same as Go sources