mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
fix: retrieve runtime gopath & goroot
This commit is contained in:
parent
fbbed9b992
commit
9ba42b74c6
@ -1,10 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/foomo/gotsrpc/v2"
|
||||
"github.com/foomo/gotsrpc/v2/config"
|
||||
@ -35,11 +36,26 @@ func main() {
|
||||
}
|
||||
gotsrpc.ReaderTrace = *flagDebug
|
||||
|
||||
var goRoot string
|
||||
var goPath string
|
||||
if out, err := exec.Command("go", "env", "GOROOT").Output(); err != nil {
|
||||
fmt.Println("failed to retrieve GOROOT", err.Error())
|
||||
os.Exit(1)
|
||||
} else {
|
||||
goRoot = string(bytes.TrimSpace(out))
|
||||
}
|
||||
if out, err := exec.Command("go", "env", "GOPATH").Output(); err != nil {
|
||||
fmt.Println("failed to retrieve GOPATH", err.Error())
|
||||
os.Exit(1)
|
||||
} else {
|
||||
goPath = string(bytes.TrimSpace(out))
|
||||
}
|
||||
|
||||
conf, err := config.LoadConfigFile(args[0])
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "config load error, could not load config from", args[0], ":", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
gotsrpc.Build(conf, build.Default.GOPATH, build.Default.GOROOT)
|
||||
gotsrpc.Build(conf, goPath, goRoot)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user