// FromEnv uses environment variables to set the tracer's Configuration
12148
func FromEnv() (*Configuration, error) {
	c := &Configuration{}

	if e := os.Getenv(envServiceName); e != "" {
		c.ServiceName = e
	}

	if e := os.Getenv(envRPCMetrics); e != "" {
		if value, err := strconv.ParseBool(e); err == nil {
			c.RPCMetrics = value
		} else {
			return nil, errors.Wrapf(err, "cannot parse env var %s=%s", envRPCMetrics, e)
		}
	}

	if e := os.Getenv(envDisabled); e != "" {
		if value, err := strconv.ParseBool(e); err == nil {
			c.Disabled = value
		} else {
			return nil, errors.Wrapf(err, "cannot parse env var %s=%s", envDisabled, e)
		}
	}

	if e := os.Getenv(envTags); e != "" {
		c.Tags = parseTags(e)
	}

	if s, err := samplerConfigFromEnv(); err == nil {
		c.Sampler = s
	} else {
		return nil, errors.Wrap(err, "cannot obtain sampler config from env")
	}

	if r, err := reporterConfigFromEnv(); err == nil {
		c.Reporter = r
	} else {
		return nil, errors.Wrap(err, "cannot obtain reporter config from env")
	}

	return c, nil
}
162039
func (c *ServerContext) SetEnv(key, val string) {
	c.env[key] = val
}
1248818
func (b *binary) AddEnv(entry string) {
	b.env = append(b.env, entry)
}
534276
func (m *Module) Getenv(key string) string {
	if _, ok := m.Env[key]; !ok {
		m.Env[key] = os.Getenv(key)
	}
	return m.Env[key]
}
63334
func SetEnv(e Environment) {
	if e != DEV && e != STAGE && e != PROD {
		internalLog.Warn("could not set unknown environment value, ignoring")
		return
	}
	if e != GetEnv() {
		internalLog.
			WithField("prevEnv", GetEnv()).
			WithField("newEnv", e).
			Warn("Setting a new environment")
	}
	if e == PROD {
		Logger.Level = log.InfoLevel
		enableDebug = false
	} else {
		enableDebug = true
		Logger.Level = log.DebugLevel
	}
	atomic.StoreInt32(currentEnvironment, int32(e))
}
500082
func (c Context) Env() map[string]string {
	osEnv := os.Environ()
	envVars := make(map[string]string, len(osEnv))
	for _, env := range osEnv {
		data := strings.SplitN(env, "=", 2)
		if len(data) == 2 && len(data[0]) > 0 {
			envVars[data[0]] = data[1]
		}
	}
	return envVars
}
403256
func LocalEnv() Environment {
	env := applyEnvFlags(Environment{Name: "local", Repo: "ethereum/go-ethereum"})

	head := readGitFile("HEAD")
	if splits := strings.Split(head, " "); len(splits) == 2 {
		head = splits[1]
	} else {
		return env
	}
	if env.Commit == "" {
		env.Commit = readGitFile(head)
	}
	if env.Branch == "" {
		if head != "HEAD" {
			env.Branch = strings.TrimPrefix(head, "refs/heads/")
		}
	}
	if info, err := os.Stat(".git/objects"); err == nil && info.IsDir() && env.Tag == "" {
		env.Tag = firstLine(RunGit("tag", "-l", "--points-at", "HEAD"))
	}
	return env
}
160938
func (c *Command) AppendEnv(env string) {
	if c.cmd.Env != nil {
		c.cmd.Env = append(c.cmd.Env, env)
		return
	}
	c.cmd.Env = append(os.Environ(), env)
}
94403
func Env(key string, defaultValue string) string {
	val := os.Getenv(key)
	if len(val) == 0 {
		return defaultValue
	}
	return val
}
1246241
func GetEnv(envName, defaultValue string) string {
	value := os.Getenv(envName)
	if value == "" {
		return defaultValue
	}
	return value
}
41087
func GetServeEnv() (ServeEnv, error) {
	var serveEnv ServeEnv
	if err := env.Populate(&serveEnv); err != nil {
		return ServeEnv{}, err
	}
	return serveEnv, nil
}
302745
func GetAppEnv() (AppEnv, error) {
	appEnv := AppEnv{}
	if err := env.Populate(&appEnv); err != nil {
		return AppEnv{}, err
	}
	return appEnv, nil
}
519344
func UnsetEnv(name string) error {
	env, err := Load()
	if err != nil {
		return fmt.Errorf("failed to load environment: %v", err)
	}
	env.Setters = filter(env.Setters, func(nv NameValue) bool {
		return nv.Name != name
	})
	env.Appenders = filter(env.Appenders, func(nv NameValue) bool {
		return nv.Name != name
	})
	env.Unsetters = filter(env.Unsetters, func(nv NameValue) bool {
		return nv.Name != name
	})
	env.Unsetters = append(env.Unsetters, NameValue{name, ""})

	err = Save(env)
	if err != nil {
		return fmt.Errorf("failed to save environment: %v", err)
	}
	return nil
}
926179
func Environment(key string) *configSource {
	configString := os.Getenv(key)
	return &configSource{
		skip: configString == "",
		from: fmt.Sprintf("'%s' environment variable", key),
		apply: func(baseConfig interface{}) error {
			return FromString(configString, baseConfig)
		},
	}
}
563304
func environ() (env []string) {
	for _, v := range os.Environ() {
		if !strings.HasPrefix(v, "GOPATH=") {
			env = append(env, v)
		}
	}
	env = append(env, "GOPATH="+gopath)
	return
}
725593
func (c *Config) EnvVars() map[string]string {
	vars := make(map[string]string, len(c.Params))
	for _, p := range c.Params {
		k, v := p.EnvVars()
		vars[k] = v
	}
	return vars
}
223858
func GoEnv(name, line string) (value string, ok bool) {
	// Remove any leading "set " found on windows.
	// Match the name to the env var + "=".
	// Remove any quotes.
	// Return result.
	line = strings.TrimPrefix(line, "set ")
	if len(line) < len(name)+1 {
		return "", false
	}
	if name != line[:len(name)] || line[len(name)] != '=' {
		return "", false
	}
	line = line[len(name)+1:]
	if un, err := strconv.Unquote(line); err == nil {
		line = un
	}
	return line, true
}