MCPcopy
hub / github.com/restic/restic / build

Function build

build.go:126–154  ·  view source on GitHub ↗

build runs "go build args..." with GOPATH set to gopath.

(cwd string, env map[string]string, args ...string)

Source from the content-addressed store, hash-verified

124
125// build runs "go build args..." with GOPATH set to gopath.
126func build(cwd string, env map[string]string, args ...string) error {
127 // -trimpath removes all absolute paths from the binary.
128 a := []string{"build", "-trimpath"}
129
130 if enablePIE {
131 a = append(a, "-buildmode=pie")
132 }
133
134 a = append(a, args...)
135 cmd := exec.Command("go", a...)
136 cmd.Env = os.Environ()
137 for k, v := range env {
138 cmd.Env = append(cmd.Env, k+"="+v)
139 }
140 if !enableCGO {
141 cmd.Env = append(cmd.Env, "CGO_ENABLED=0")
142 }
143
144 printEnv(cmd.Env)
145
146 cmd.Dir = cwd
147 cmd.Stdout = os.Stdout
148 cmd.Stderr = os.Stderr
149
150 verbosePrintf("chdir %q\n", cwd)
151 verbosePrintf("go %q\n", a)
152
153 return cmd.Run()
154}
155
156// test runs "go test args..." with GOPATH set to gopath.
157func test(cwd string, env map[string]string, args ...string) error {

Callers 1

mainFunction · 0.70

Calls 3

printEnvFunction · 0.85
verbosePrintfFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected