Open sio4 opened 2 years ago
Removing the default Overload()
would be very welcome. For traditional UNIX folks who expect var=value someprogram
to override any file-based configuration (particularly in absence of godotenv.Overload()
calls within someprogram
's source), this is a serious violation of principle-of-least-surprise.
Progress
Direction
os.Getenv()
families with virtual features like envy only env or sandbox.env
auto-loading or change it to manualContext
Envy is currently used by cli, buffalo, pop, meta v0, and clara. Also, the generated app uses it for mostly
.env
support which is a nice thing.Currently, envy provides the following public functions:
Main Functions:
Get(key string, value string) string
- returns a value from the ENV, otherwise returns the given defaultMustGet(key string) (string, error)
- returns a value from the ENV. no default but returns an errorSet(key string, value string)
- sets the value only into envy, not on the underlying ENVMustSet(key string, value string) error
- sets the value into the underlying ENV, as well as envy.Utilities:
Environ() []string
- returns an array of env representationLoad(files ...string) error
- load .env filesReload()
- reload the ENV variablesMap() map[string]string
- returns all of the keys/values set in envy (no module uses it)Temp(f func())
- a kind of sandbox --> still useful for testingRelated to the golang environment:
GoBin() string
- returns "GO_BIN", just a wrapper ofGet("GO_BIN", "go")
GoPath() string
- returns "GOPATH", just a wrapper ofGet("GOPATH", "")
GoPaths() []string
- returns all possible GOPATH that are set --> could be deprecatedInGoPath() bool
- check if the current working directory is within GOPATH --> could be deprecatedCurrentModule() (string, error)
- return the module name fromgo.mod
--> could be deprecatedAlso, it provides
.env
loading.I don't think golang-related functions are still useful. All could be deprecated.
@gobuffalo/core-managers what do you think?