Skip to content

Commit

Permalink
Rename all 'yml' structure tags to 'yaml'
Browse files Browse the repository at this point in the history
according to gopkg.in/yaml.v2 documentation

Signed-off-by: Ilya Kaznacheev <[email protected]>
  • Loading branch information
ilyakaznacheev committed Feb 7, 2020
1 parent c3e8a6c commit 367ca27
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ You can read a configuration file and environment variables in a single function
import github.com/ilyakaznacheev/cleanenv

type ConfigDatabase struct {
Port string `yml:"port" env:"PORT" env-default:"5432"`
Host string `yml:"host" env:"HOST" env-default:"localhost"`
Name string `yml:"name" env:"NAME" env-default:"postgres"`
User string `yml:"user" env:"USER" env-default:"user"`
Password string `yml:"password" env:"PASSWORD"`
Port string `yaml:"port" env:"PORT" env-default:"5432"`
Host string `yaml:"host" env:"HOST" env-default:"localhost"`
Name string `yaml:"name" env:"NAME" env-default:"postgres"`
User string `yaml:"user" env:"USER" env-default:"user"`
Password string `yaml:"password" env:"PASSWORD"`
}

var cfg ConfigDatabase
Expand Down Expand Up @@ -271,8 +271,8 @@ fset.Parse(os.Args[1:])

```go
type Config struct {
Port string `yml:"port" env:"PORT" env-default:"8080"`
Host string `yml:"host" env:"HOST" env-default:"localhost"`
Port string `yaml:"port" env:"PORT" env-default:"8080"`
Host string `yaml:"host" env:"HOST" env-default:"localhost"`
}

var cfg Config
Expand Down
16 changes: 8 additions & 8 deletions cleanenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Package cleanenv gives you a single tool to read application configuration from
You can just prepare config structure and fill it from the config file and environment variables.
type Config struct {
Port string `yml:"port" env:"PORT" env-default:"8080"`
Host string `yml:"host" env:"HOST" env-default:"localhost"`
Port string `yaml:"port" env:"PORT" env-default:"8080"`
Host string `yaml:"host" env:"HOST" env-default:"localhost"`
}
var cfg Config
Expand Down Expand Up @@ -64,11 +64,11 @@ type Updater interface {
// Example:
//
// type ConfigDatabase struct {
// Port string `yml:"port" env:"PORT" env-default:"5432"`
// Host string `yml:"host" env:"HOST" env-default:"localhost"`
// Name string `yml:"name" env:"NAME" env-default:"postgres"`
// User string `yml:"user" env:"USER" env-default:"user"`
// Password string `yml:"password" env:"PASSWORD"`
// Port string `yaml:"port" env:"PORT" env-default:"5432"`
// Host string `yaml:"host" env:"HOST" env-default:"localhost"`
// Name string `yaml:"name" env:"NAME" env-default:"postgres"`
// User string `yaml:"user" env:"USER" env-default:"user"`
// Password string `yaml:"password" env:"PASSWORD"`
// }
//
// var cfg ConfigDatabase
Expand Down Expand Up @@ -153,7 +153,7 @@ func parseTOML(r io.Reader, str interface{}) error {
// parseENV, in fact, doesn't fill the structure with environment variable values.
// It just parses ENV file and sets all variables to the environment.
// Thus, the structure should be filled at the next steps.
func parseENV(r io.Reader, str interface{}) error {
func parseENV(r io.Reader, _ interface{}) error {
vars, err := godotenv.Parse(r)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion example/simple_config/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Simple config

Example of simple web server reding configuration from the config file and environment variables.
Example of simple web server reading configuration from the config file and environment variables.

In this example, some fields are not stored in the default configuration file (`config.yml`) by security reasons. Store passwords and other sensitive parameters in secure storage and read them from environment variables.

0 comments on commit 367ca27

Please sign in to comment.