-
Notifications
You must be signed in to change notification settings - Fork 126
Updated GetDescription function and ReadEnv. #59
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
base: master
Are you sure you want to change the base?
Updated GetDescription function and ReadEnv. #59
Conversation
Now user can see more userful information then earlier.
In particular, GetDescription function return text with
information with "required" line.
See example below:
Environment variables:
GREETING string
Greeting phrase
Default: "Hello!"
Required: true
DB_HOST string
Database host
Required: true
DB_PORT string
Database port
Required: true
DB_USER string
Database user name
Required: true
DB_PASSWORD string
Database user password
Required: true
DB_NAME string
Database name
Required: true
Error from ReadEnv contains information not only about
structure's field, but about env variables for this field as well.
"field "Host" is required but the value is not provided.
Envs names: "SRV_HOST HOST""
Also, all test changed for the last changes.
Codecov Report
@@ Coverage Diff @@
## master #59 +/- ##
==========================================
+ Coverage 89.79% 89.95% +0.16%
==========================================
Files 1 1
Lines 245 249 +4
==========================================
+ Hits 220 224 +4
Misses 17 17
Partials 8 8
Continue to review full report at Codecov.
|
| @@ -1,4 +1,4 @@ | |||
| module github.com/ilyakaznacheev/cleanenv | |||
| module github.com/mashinapetro/cleanenv | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change back to ilyakaznacheev
| envList := "" | ||
| for _, env := range meta.envList { | ||
| envList = envList + env + " " | ||
| } | ||
| envList = strings.Trim(envList, " ") | ||
| err := fmt.Errorf("field %q is required but the value is not provided. Envs names: %q", | ||
| meta.fieldName, envList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really don't need this part, because the value can come from any source - env, yaml, toml, json, etc. The only thing we know is that the value is empty, and there is a message about it.
Hey, Ilya!
Your project is awesome!
I've tried about 10 similar project, but your is the best.
I propose some changes, which very useful in real production - more informative info from GetDescription method and more information when ReadEnv returns errors.
See detailed description and examples below.
Now user can see more userful information then earlier.
In particular, GetDescription function return text with
information with "required" line.
See example below:
Error from ReadEnv contains information not only about
structure's field, but about env variables for this field as well.
field "Host" is required but the value is not provided. Envs names: "SRV_HOST HOST"Also, all test changed for the last changes.