FeatureRequest: `_FILE` suffix to env vars
- Dominant language
- Go
- Stars
- 6.3k
- Forks
- 284
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 1
Description
I believe adding support to `_FILE` suffixes would be a great addition to this library. There are cases where we may want to load data not from the env, but from a secret file, like `/run/secrets/`, and although the library already supports the `,file` option, that would require the user to have a struct like:
```go
type Config struct {
Password `env:"PASSWORD"`
PasswordFile `env:"PASSWORD_FILE,file"`
}
```
My proposal is to have an option that enables this feature globally, or by field:
**By Field:**
```go
type Config struct {
Password `env:"PASSWORD,allow_file_suffix"`
}
```
**Global:**
```go
type Config struct {
Password `env:"PASSWORD"`
}
conf := Config{}
env.ParseWithOptions(&conf, env.Options{
AllowFileSuffix: True
})
```
If you find it interesting to add, I would love to work on the feature myself.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the existing `,file` option and the `env.ParseWithOptions` and `env.Options` entry points. Compare the proposed field tag `allow_file_suffix` with the global `AllowFileSuffix` option, then trace how environment names and secret files are resolved. Done means both configuration forms support the `_FILE` convention without breaking existing `,file` behavior, with tests covering each form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100