From ea8b77b2ec9582a0fdd1ca686dd555a260277657 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sat, 1 Aug 2015 22:53:59 -0300 Subject: [PATCH] Update README.md --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3d91ed5..c9e0996 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,20 @@ A KISS way to deal with environment variables in Go. ## Why At first, it was boring for me to write down an entire function just to -get some var from the environment and default to another in case it's missing. +get some `var` from the environment and default to another in case it's missing. -For that manner, I wrote the `GetOr` function. +For that manner, I wrote a `GetOr` function in the +[go-idioms](https://github.com/caarlos0/go-idioms) project. Then, I got pissed about writing `os.Getenv`, `os.Setenv`, `os.Unsetenv`... it kind of make more sense to me write it as `env.Get`, `env.Set`, `env.Unset`. - So I did. -Then I got a better idea: to use struct tags to do that work for me. +Then I got a better idea: to use `struct` tags to do all that work for me. ## Example -The most basic example (check the `examples` folder): +A very basic example (check the `examples` folder): ```go package main @@ -40,7 +40,7 @@ func main() { os.Setenv("HOME", "/tmp/fakehome") cfg := config{} env.Parse(&cfg) - fmt.Println(cfg) // {/tmp/fakehome 3000 false} + fmt.Println(cfg) } ``` @@ -48,6 +48,7 @@ You can run it like this: ```sh $ PRODUCTION=true go run examples/first.go +{/tmp/fakehome 3000 false} ``` ## Supported types and defaults @@ -57,5 +58,6 @@ Currently we only support `string`, `bool` and `int`. If you set the `envDefault` tag for something, this value will be used in the case of absence of it in the environment. If you don't do that AND the environment variable is also not set, the zero-value -of the type will be used: `` (empty) for strings, `false` for bools -and `0` for ints. +of the type will be used: empty for `string`s, `false` for `bool`s +and `0` for `int`s. +