You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All svc1log functions that determine the origin based off of the call stack are not module aware.
The internal function initLineCaller gets the filename and line number of the calling function via the runtime.Caller method and then uses a simple heuristic to remove the GOPATH specific prefix of /src/. Removing the GOPATH prefix does not work for projects that use go modules, since they no longer need to be rooted in the GOPATH, which then results in an incorrect pkg based origin.
For example, if GOPATH=/home/tabboud/go/src, the following will be returned for the svc1log.CallerPkg(0, 1) function call from the test-repo/server/server.go file:
What happened?
All svc1log functions that determine the origin based off of the call stack are not module aware.
The internal function
initLineCaller
gets the filename and line number of the calling function via theruntime.Caller
method and then uses a simple heuristic to remove the GOPATH specific prefix of/src/
. Removing the GOPATH prefix does not work for projects that use go modules, since they no longer need to be rooted in the GOPATH, which then results in an incorrect pkg based origin.For example, if
GOPATH=/home/tabboud/go/src
, the following will be returned for thesvc1log.CallerPkg(0, 1)
function call from thetest-repo/server/server.go
file:What did you want to happen?
The return value should be
"github.com/tabboud/test-repo"
, no matter if the repo was in or out of the GOPATH.The text was updated successfully, but these errors were encountered: