fix: pass goroot

This commit is contained in:
Kevin Franklin Kim 2025-03-18 07:32:26 +01:00
parent 5debe54950
commit a332d9564f
No known key found for this signature in database
2 changed files with 8 additions and 5 deletions

View File

@ -7,7 +7,6 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"sort"
"strings"
@ -63,7 +62,7 @@ func getPathForTarget(gomod config.Namespace, goPath string, target *config.Targ
}
}
func Build(conf *config.Config, goPath string) { //nolint:maintidx
func Build(conf *config.Config, goRoot, goPath string) { //nolint:maintidx
deriveCommonJSMapping(conf)
mappedTypeScript := map[string]map[string]*code{}
@ -120,7 +119,7 @@ func Build(conf *config.Config, goPath string) { //nolint:maintidx
}
vendorDirectory := path.Join(workDirectory, "vendor")
goPaths := []string{goPath, runtime.GOROOT()}
goPaths := []string{goPath, goRoot}
if _, err := os.Stat(vendorDirectory); !os.IsNotExist(err) {
goPaths = append(goPaths, vendorDirectory)

View File

@ -37,7 +37,11 @@ func main() {
// check if GOPATH has been set as env variable
// if not use the default from the build pkg
goPath := os.Getenv("GOROOT")
goPath := os.Getenv("GOPATH")
if goPath == "" {
goPath = build.Default.GOPATH
}
goRoot := os.Getenv("GOROOT")
if goPath == "" {
goPath = build.Default.GOROOT
}
@ -47,5 +51,5 @@ func main() {
fmt.Fprintln(os.Stderr, "config load error, could not load config from", args[0], ":", err)
os.Exit(2)
}
gotsrpc.Build(conf, goPath)
gotsrpc.Build(conf, goRoot, goPath)
}