Comments (5)
I ran into this problem too, and I notice Kelsey Hightower's envconfig package also does not check whether the field you are attempting to set is unexported. Assuming there is no other case where a developer would set the env
tag on an unexported field other than intending for that field to be exported, should unexported fields with env
tags throw errors? (https://groups.google.com/g/golang-nuts/c/i50jwcgHAcs)
from cleanenv.
This is a standard and expected behavior of Golang - library cannot read unexported fields from another package.
The expected behavior it that such fields will be ignored.
from cleanenv.
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method
goroutine 1 [running]:
reflect.valueInterface({0x95f8a0?, 0xc00055c248?, 0xabea8f?}, 0xa?)
E:/software/dev_core/go1.18.1/src/reflect/value.go:1441 +0xd8
reflect.Value.Interface(...)
E:/software/dev_core/go1.18.1/src/reflect/value.go:1430
github.com/ilyakaznacheev/cleanenv.readStructMetadata({0x9c7900?, 0xc00055c1c0?})
E:/text/code-project/GolangProject/pkg/mod/github.com/ilyakaznacheev/[email protected]/cleanenv.go:274 +0x771
github.com/ilyakaznacheev/cleanenv.readEnvVars({0x9c7900, 0xc00055c1c0}, 0x0)
E:/text/code-project/GolangProject/pkg/mod/github.com/ilyakaznacheev/[email protected]/cleanenv.go:333 +0x45
github.com/ilyakaznacheev/cleanenv.ReadConfig({0xace493?, 0xc00041f9a8?}, {0x9c7900, 0xc00055c1c0})
E:/text/code-project/GolangProject/pkg/mod/github.com/ilyakaznacheev/[email protected]/cleanenv.go:95 +0x48
It doesn't skip unexport field
from cleanenv.
@838239178 can you provide a code example, please?
from cleanenv.
Better create a new issue with an example and detailed error and environment description. Thanks
from cleanenv.
Related Issues (20)
- Create a version compatibility policy
- Didn't skip unexported field HOT 4
- Apply Custom Value Setters to custom struct types
- Does this support parsing `map[string]CustomStruct` using the `env` tag? HOT 2
- How about adding the ability to use dynamic values in a config file? HOT 1
- What is the correct location for the config.yml? HOT 4
- Set but empty Environment Variables don't raise an error HOT 1
- Nested structures not sorted HOT 2
- [][]string from env HOT 1
- Setup env parameter for array in config? HOT 1
- Config returns nothing
- Update GetDescription to show which variables are required
- print the name of the env var in the error message when a required var is missing rather than just the struct field name HOT 1
- Allow reading from `fs.FS`
- Return wrapped error with "%w" verb instead of "%s"
- File decodes based on extension, meaning it fails to load config if `.rc` files are used
- env-required pretty limited usage
- Example of using map of structs in config, example of using `env-separator`
- It changes the set 0 to the default value.
- Can't read config file in Amazon EC2 server HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cleanenv.