/usr/share/gocode/src/github.com/constabulary/gb/cmd/env.go is in golang-github-constabulary-gb-dev 0.4.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | package cmd
import (
"fmt"
"log"
"os"
"strings"
)
// MustGetwd returns current working directory and fails otherwise
func MustGetwd() string {
wd, err := os.Getwd()
if err != nil {
log.Fatalf("unable to determine current working directory: %v", err)
}
return wd
}
// MergeEnv merges args into env, overwriting entries.
func MergeEnv(env []string, args map[string]string) []string {
m := make(map[string]string)
for _, e := range env {
v := strings.SplitN(e, "=", 2)
m[v[0]] = v[1]
}
for k, v := range args {
m[k] = v
}
env = make([]string, 0, len(m))
for k, v := range m {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
return env
}
|