// UnsetEnv permanently unsets an environment variable
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
}
19606
func (s *CreateProjectInput) SetEnvironment(v *ProjectEnvironment) *CreateProjectInput {
	s.Environment = v
	return s
}
151063
func (ev *EnvVars) Restore() {
	for key, value := range ev.vars {
		if err := os.Setenv(key, value); err != nil {
			msg := fmt.Sprintf("cannot reset environment variable %q: %v", key, err)
			ev.assert.Fail(msg)
		}
	}
}
417937
func WithSetenv(ctx context.Context, f setenvFunc) context.Context {
	return context.WithValue(ctx, ctxOSSetenvKey, f)
}
1098019
func (c *ServerContext) GetEnv(key string) (string, bool) {
	val, ok := c.env[key]
	return val, ok
}
601140
func (s *ContainerDefinition) SetEnvironment(v map[string]*string) *ContainerDefinition {
	s.Environment = v
	return s
}
452740
func (s *Stubs) SetEnv(k, v string) *Stubs {
	s.checkEnvKey(k)

	os.Setenv(k, v)
	return s
}
616944
func splitEnv(item string) (key, val string) {
	splits := strings.Split(item, "=")
	key = splits[0]
	val = strings.Join(splits[1:], "=")
	return
}
650457
func SetKeyEnv() (err error) {
	_key = os.Getenv("STRIPE_API_KEY")
	if _key == "" {
		err = errors.New("STRIPE_API_KEY not found in environment")
	}
	return
}
655040
func ParseEnv(v interface{}) error {
	env, err := parseEnvironment()
	if err != nil {
		return err
	}
	s := reflect.ValueOf(v).Elem()
	return setEnv(s, env)
}
38309
func (c *CommandLabels) SetEnv(v string) error {
	if err := json.Unmarshal([]byte(v), c); err != nil {
		return trace.Wrap(err, "can not parse Command Labels")
	}
	return nil
}
1192175
func (c *Configuration) CheckEnv() error {
	if c.ActiveEnv == "" {
		return fmt.Errorf("No active environment chosen. Please choose an environment using the \"env\" flag in config.toml or the $%s_ENV environment variable", c.AppEnvName)
	}
	return nil
}
1319712
func (e *Env) NewEnv() *Env {
	return &Env{
		env:    make(map[string]reflect.Value),
		typ:    make(map[string]reflect.Type),
		parent: e,
		name:   e.name,
	}
}
260544
func (l *LimiterConfig) SetEnv(v string) error {
	if err := json.Unmarshal([]byte(v), l); err != nil {
		return trace.Wrap(err, "expected JSON encoded remote certificate")
	}
	return nil
}
162039
func (c *ServerContext) SetEnv(key, val string) {
	c.env[key] = val
}
915039
func splitEnv(env []string) (map[string]string, error) {
	out := map[string]string{}

	for _, s := range env {
		parts := strings.SplitN(s, "=", 2)
		if len(parts) != 2 {
			return nil, fmt.Errorf("badly formatted environment variable: %v", s)
		}
		out[parts[0]] = parts[1]
	}
	return out, nil
}
649573
func mergeEnv(sysEnv []string, cmdEnv map[string]string) []string {
	var env []string
	// cmdEnv has precedence and overwrites any duplicate vars
	for k, v := range cmdEnv {
		env = append(env, k+"="+v)
	}
	for _, s := range sysEnv {
		if n := strings.IndexByte(s, '='); n != -1 {
			k := s[:n] // key
			if _, found := cmdEnv[k]; !found {
				env = append(env, s)
			}
		}
	}
	return env
}