Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should CurrentPackage() be deprecated? #37

Closed
sio4 opened this issue Oct 30, 2021 · 0 comments · Fixed by #39
Closed

should CurrentPackage() be deprecated? #37

sio4 opened this issue Oct 30, 2021 · 0 comments · Fixed by #39

Comments

@sio4
Copy link
Member

sio4 commented Oct 30, 2021

This implementation is based on the legacy layout of GOPATH which is deprecated now. It seems like CurrentModule() should be used for the same purpose. Any idea?

envy/envy.go

Lines 218 to 232 in 3dbe4c9

func importPath(path string) string {
path = strings.TrimPrefix(path, "/private")
for _, gopath := range GoPaths() {
srcpath := filepath.Join(gopath, "src")
rel, err := filepath.Rel(srcpath, path)
if err == nil {
return filepath.ToSlash(rel)
}
}
// fallback to trim
rel := strings.TrimPrefix(path, filepath.Join(GoPath(), "src"))
rel = strings.TrimPrefix(rel, string(filepath.Separator))
return filepath.ToSlash(rel)
}

envy/envy.go

Lines 254 to 259 in 3dbe4c9

func CurrentPackage() string {
if Mods() {
}
pwd, _ := os.Getwd()
return importPath(pwd)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant