From a332d9564f7c852e90c73e3e1cef1e87e259e5fe Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Tue, 18 Mar 2025 07:32:26 +0100 Subject: [PATCH] fix: pass goroot --- build.go | 5 ++--- cmd/gotsrpc/gotsrpc.go | 8 ++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build.go b/build.go index efcf0f7..04b46cd 100644 --- a/build.go +++ b/build.go @@ -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) diff --git a/cmd/gotsrpc/gotsrpc.go b/cmd/gotsrpc/gotsrpc.go index cb9cea7..e57908f 100644 --- a/cmd/gotsrpc/gotsrpc.go +++ b/cmd/gotsrpc/gotsrpc.go @@ -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) }