Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Add support for Go Modules #236

Open
kamilogorek opened this issue Jan 31, 2019 · 2 comments
Open

Add support for Go Modules #236

kamilogorek opened this issue Jan 31, 2019 · 2 comments

Comments

@kamilogorek
Copy link
Contributor

I couldn't find any reliable way to extract current package name, as in here:

raven-go/stacktrace_test.go

Lines 109 to 135 in 238ebd8

func derivePackage() (file, pack string) {
// Get file name by seeking caller's file name.
_, callerFile, _, ok := runtime.Caller(1)
if !ok {
return
}
// Trim file name
file = callerFile
for _, dir := range build.Default.SrcDirs() {
dir := dir + string(filepath.Separator)
if trimmed := strings.TrimPrefix(callerFile, dir); len(trimmed) < len(file) {
file = trimmed
}
}
// Now derive package name
dir := filepath.Dir(callerFile)
dirPkg, err := build.ImportDir(dir, build.AllowBinary)
if err != nil {
return
}
pack = dirPkg.ImportPath
return
}
due to Go Modules not using GOPATH anymore.
Need more investigation.

Some sources:
https://github.com/golang/go/wiki/Modules#migrating-to-modules
https://research.swtch.com/vgo-module

@tankbusta
Copy link

Is this issue why I'm seeing the raven package in the error title? (We're using modules)

theerror

@kamilogorek
Copy link
Contributor Author

I don't think so, I was able to successfully read the module name using modules as well.

Do you have any repro of this behaviour?

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

2 participants