MCPcopy
hub / github.com/dgraph-io/dgraph / ensureGoPathLinuxBinEnvVarSet

Function ensureGoPathLinuxBinEnvVarSet

t/t.go:183–200  ·  view source on GitHub ↗

ensureGoPathLinuxBinEnvVarSet sets LINUX_GOBIN environment variable if not already set. On Linux, it defaults to $GOPATH/bin. On other systems (macOS, etc.), it defaults to $GOPATH/linux_$GOARCH/bin to support cross-compiled Linux binaries for Docker tests.

()

Source from the content-addressed store, hash-verified

181// On Linux, it defaults to $GOPATH/bin. On other systems (macOS, etc.), it defaults
182// to $GOPATH/linux_$GOARCH/bin to support cross-compiled Linux binaries for Docker tests.
183func ensureGoPathLinuxBinEnvVarSet() {
184 if os.Getenv("LINUX_GOBIN") != "" {
185 return // already set
186 }
187
188 gopath := os.Getenv("GOPATH")
189 if gopath == "" {
190 gopath = filepath.Join(os.Getenv("HOME"), "go")
191 }
192
193 var gopathLinuxBin string
194 if runtime.GOOS == "linux" {
195 gopathLinuxBin = filepath.Join(gopath, "bin")
196 } else {
197 gopathLinuxBin = filepath.Join(gopath, "linux_"+runtime.GOARCH)
198 }
199 os.Setenv("LINUX_GOBIN", gopathLinuxBin)
200}
201
202// ensureDgraphLinuxBinary checks if the dgraph binary exists under LINUX_GOBIN.
203// If not found, it runs make install to build it.

Callers 2

ensureDgraphLinuxBinaryFunction · 0.85
startClusterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected