@@ -28,6 +28,11 @@ var Aliases = map[string]interface{}{
28
28
"test" : Test .All ,
29
29
}
30
30
31
+ // env returns the environment to use when running Go commands.
32
+ func env () map [string ]string {
33
+ return map [string ]string {"CGO_ENABLED" : "0" }
34
+ }
35
+
31
36
// ldFlags returns linker flags to pass to various Go commands.
32
37
func ldFlags () string {
33
38
vals := []string {"-s" , "-w" , "-X" , "main.builtBy=mage" }
@@ -71,7 +76,7 @@ func (ns Build) All() {
71
76
72
77
// Source compiles all source code.
73
78
func (Build ) Source () error {
74
- return sh .Run ( mg .GoCmd (), "build" , "-trimpath" , "-ldflags" , ldFlags (), "./..." )
79
+ return sh .RunWith ( env (), mg .GoCmd (), "build" , "-trimpath" , "-ldflags" , ldFlags (), "./..." )
75
80
}
76
81
77
82
type Install mg.Namespace
@@ -83,7 +88,7 @@ func (ns Install) All() {
83
88
84
89
// Bin installs binary to GOBIN.
85
90
func (Install ) Bin () error {
86
- return sh .Run ( mg .GoCmd (), "install" , "-trimpath" , "-ldflags" , ldFlags (), "./cmd/siftool" )
91
+ return sh .RunWith ( env (), mg .GoCmd (), "install" , "-trimpath" , "-ldflags" , ldFlags (), "./cmd/siftool" )
87
92
}
88
93
89
94
type Test mg.Namespace
0 commit comments