fix Windows file paths in local go mod cache (#2654)

Previously, the file resolver was created from incorrect calls
(path.Join instead of filepath.Join) which resulted Go license searches
always missing on Windows. Use filepath.* functions when initializing
the Go config, and when the unindexed file resolver is being created.

Signed-off-by: Will Murphy <will.murphy@anchore.com>
This commit is contained in:
William Murphy
2024-05-09 13:08:58 -04:00
committed by GitHub
parent 1892f24002
commit b2ca5fbf89
2 changed files with 8 additions and 7 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ package golang
import (
"os"
"path"
"path/filepath"
"strings"
"github.com/mitchellh/go-homedir"
@@ -75,11 +75,11 @@ func DefaultCatalogerConfig() CatalogerConfig {
if err != nil {
log.Debug("unable to determine user home dir: %v", err)
} else {
goPath = path.Join(homeDir, "go")
goPath = filepath.Join(homeDir, "go")
}
}
if goPath != "" {
g.LocalModCacheDir = path.Join(goPath, "pkg", "mod")
g.LocalModCacheDir = filepath.Join(goPath, "pkg", "mod")
}
}
return g