There is no good way to do it apart from making package level "ErrSomething" sentinel error variables. At least that way it ends up in the package documentation.

Another thing people need to get better at in Go is to use errors.Join() to provide both API level error and root cause.

Comments