Skip to content

Commit

Permalink
hack this a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
peterebden committed Dec 18, 2023
1 parent 76ce8a2 commit 7a77e2b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/please_go/packageinfo/packageinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"sort"
"strings"

Expand Down Expand Up @@ -110,7 +111,13 @@ func FromBuildPackage(pkg *build.Package, subrepo string) *packages.Package {
Imports: make(map[string]*packages.Package, len(pkg.Imports)),
}
for i, file := range pkg.GoFiles {
p.GoFiles[i] = filepath.Join(subrepo, pkg.Dir, file)
if subrepo != "" {
// this is fairly nasty... there must be a better way of getting it without the pkg/ prefix
dir := strings.TrimPrefix(pkg.Dir, "pkg/"+runtime.GOOS+"_"+runtime.GOARCH)
p.GoFiles[i] = filepath.Join(subrepo, dir, file)
} else {
p.GoFiles[i] = filepath.Join(pkg.Dir, file)
}
}
p.CompiledGoFiles = p.GoFiles // This seems to be important to e.g. gosec
for _, imp := range pkg.Imports {
Expand Down

0 comments on commit 7a77e2b

Please sign in to comment.