Why go does not have nice backtraces
Collecting stacktraces is expensive, so the core language will never implement them for everything.
If you need your code to be highly performant then consider making a error wrapper that can be turned on/off based on a environment variable.
Simple fix
import github.com/pkg/errors and use it instead of errors package (it is deprecated but works fine)
always errors.Wrap, errrors.New, or errors.Errorf from “github.com/pkg/errors” when passing from outside your code or creating errors
when subsequently passing errors along, a return err or return fmt.Errorf("building foo: %w", err) can be used (multiple wraps create multiple backtraces which is noisy but not a big problem)
in your main.go add this:
Nicer fix
Use a more complete solution like eris.