proposal: envy v2 just as an enhanced version of `os.Getenv()`
Opened this issue · 1 comments
sio4 commented
Progress
- #41
- deprecating unwanted functions and clean up APIs
Direction
- just make it as an enhanced version of
os.Getenv()
families with virtual features like envy only env or sandbox - also keep the feature of
.env
auto-loading or change it to manual - make it simple and straight forward
Context
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 testing
- Related 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 deprecated- most of them are only used in meta v0
Also, 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?
charles-dyfis-net commented
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.