gobuffalo/envy

should `CurrentPackage()` be deprecated?

Closed this issue · 0 comments

sio4 commented

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)
}