代码拉取完成,页面将自动刷新
package procs
import (
"fmt"
"os"
"strings"
)
// ParseEnv takes an environment []string and converts it to a map[string]string.
func ParseEnv(environ []string) map[string]string {
env := make(map[string]string)
for _, e := range environ {
pair := strings.SplitN(e, "=", 2)
// There is a chance we can get an env with empty values
if len(pair) == 2 {
env[pair[0]] = pair[1]
}
}
return env
}
// Env takes a map[string]string and converts it to a []string that
// can be used with exec.Cmd. The useEnv boolean flag will include the
// current process environment, overlaying the provided env
// map[string]string.
func Env(env map[string]string, useEnv bool) []string {
envlist := []string{}
// update our env by loading our env and overriding any values in
// the provided env.
if useEnv {
environ := ParseEnv(os.Environ())
for k, v := range env {
environ[k] = v
}
env = environ
}
for key, val := range env {
if key == "" {
continue
}
envlist = append(envlist, fmt.Sprintf("%s=%s", key, val))
}
return envlist
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。