Skip to main content

One post tagged with "go"

View All Tags

Adding context to errors in Go

· 4 min read
Yaroslav Grebnov
Golang developer, SDET

This post compares two ways to enrich Go errors — both sentinel and typed — with additional context:

  • github.com/ygrebnov/errorc.With
  • the standard fmt.Errorf approach

The main difference is not only syntax. errorc gives you a more structured way to attach fields, and it works especially well together with github.com/ygrebnov/keys when you want stable hierarchical field names such as user.id or request.trace_id.