This may not be the exact answer you're looking for, but there's a package
which handles this even better than Go's builtin error package:
https://github.com/pkg/errors
Dave Cheney's package is better designed, IMO, and the explicit
errors.Wrap() call is more clear than inferring it from your
I think that in general you will have to only use features available to Go
1.11, meaning, of course, that the new methods in the errors package would
be off limits. In the mean time you could use golang.org/x/xerrors, which
is a superset of the new errors package and I believe will work with 1.11.
I have upgraded my code to Go 1.13 with newly introduced errors APIs.
However, I am not able to upgrade the production environment Go version
which is Go 1.11, which means I have to run Go 1.13 code on a Go 1.11
environment.
What are the way to make my builds both happy on local and production