Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: envy v2 just as an enhanced version of os.Getenv() #42

Open
1 of 2 tasks
sio4 opened this issue Jul 23, 2022 · 1 comment
Open
1 of 2 tasks

proposal: envy v2 just as an enhanced version of os.Getenv() #42

sio4 opened this issue Jul 23, 2022 · 1 comment
Assignees
Labels
breaking change This feature / fix introduces breaking changes enhancement New feature or request
Milestone

Comments

@sio4
Copy link
Member

sio4 commented Jul 23, 2022

Progress

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:

  1. Main Functions:
  • Get(key string, value string) string - returns a value from the ENV, otherwise returns the given default
  • MustGet(key string) (string, error) - returns a value from the ENV. no default but returns an error
  • Set(key string, value string) - sets the value only into envy, not on the underlying ENV
  • MustSet(key string, value string) error - sets the value into the underlying ENV, as well as envy.
  1. Utilities:
  • Environ() []string - returns an array of env representation
  • Load(files ...string) error - load .env files
  • Reload() - reload the ENV variables
  • Map() 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
  1. Related to the golang environment:
  • GoBin() string - returns "GO_BIN", just a wrapper of Get("GO_BIN", "go")
  • GoPath() string - returns "GOPATH", just a wrapper of Get("GOPATH", "")
  • GoPaths() []string - returns all possible GOPATH that are set --> could be deprecated
  • InGoPath() bool - check if the current working directory is within GOPATH --> could be deprecated
  • CurrentModule() (string, error) - return the module name from go.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?

@sio4 sio4 added enhancement New feature or request breaking change This feature / fix introduces breaking changes labels Jul 23, 2022
@sio4 sio4 added this to the v2 milestone Jul 23, 2022
@sio4 sio4 self-assigned this Jul 23, 2022
@charles-dyfis-net
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This feature / fix introduces breaking changes enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants