Skip to content

Commit 845aad1

Browse files
authored
Merge pull request #818 from DirectXMan12/feature/avoid-underscore-proj-paths
🐛 Don't use packages.Load's underscore paths
2 parents a03ef64 + 2bc79cd commit 845aad1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmd/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ func findCurrentRepo() (string, error) {
8080
Mode: packages.NeedName, // name gives us path as well
8181
}
8282
pkgs, err := packages.Load(pkgCfg, ".")
83-
if err == nil && len(pkgs) > 0 {
83+
// NB(directxman12): when go modules are off and we're outside GOPATH and
84+
// we don't otherwise have a good guess packages.Load will fabricate a path
85+
// that consists of `_/absolute/path/to/current/directory`. We shouldn't
86+
// use that when it happens.
87+
if err == nil && len(pkgs) > 0 && len(pkgs[0].PkgPath) > 0 && pkgs[0].PkgPath[0] != '_' {
8488
return pkgs[0].PkgPath, nil
8589
}
8690

0 commit comments

Comments
 (0)