/
goenv.go
42 lines (34 loc) · 978 Bytes
/
goenv.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 The Prime Citizens
//
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package toolchain
import (
"go/build"
"os"
"path/filepath"
)
var (
GO386 = EnvOr("GO386", defaultGO386)
GOAMD64 = EnvOr("GOAMD64", defaultGOAMD64)
GOARM = EnvOr("GOARM", "7")
GOMIPS = EnvOr("GOMIPS", defaultGOMIPS)
GOMIPS64 = EnvOr("GOMIPS64", defaultGOMIPS64)
GOPPC64 = EnvOr("GOPPC64", defaultGOPPC64)
GOWASM = EnvOr("GOWASM", "")
GO_LDSO = defaultGO_LDSO
GOTOOLDIR = EnvOr("GOTOOLDIR", build.ToolDir)
Context = build.Default
GoDefaultIncludeDir = filepath.Join(Context.GOROOT, "pkg", "include")
)
func EnvOr(key, def string) string {
if x := os.Getenv(key); len(x) != 0 {
return x
}
return def
}
func Getgoextlinkenabled() string {
return EnvOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
}