github.com/blend/go-sdk@v1.20220411.3/env/option.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package env 9 10 // Option is a mutator for the options set. 11 type Option func(Vars) 12 13 // OptEnviron parses the output of `os.Environ()` 14 func OptEnviron(environ ...string) Option { 15 return func(vars Vars) { 16 var key, value string 17 for _, envVar := range environ { 18 key, value = Split(envVar) 19 if key != "" { 20 vars[key] = value 21 } 22 } 23 } 24 } 25 26 // OptSet overrides values in the set with a specific set of values. 27 func OptSet(overides Vars) Option { 28 return func(vars Vars) { 29 for key, value := range overides { 30 vars[key] = value 31 } 32 } 33 } 34 35 // OptRemove removes keys from a set. 36 func OptRemove(keys ...string) Option { 37 return func(vars Vars) { 38 for _, key := range keys { 39 delete(vars, key) 40 } 41 } 42 }