Skip to content
/ goenv Public

Library for loading settings from environment variables

License

Notifications You must be signed in to change notification settings

l-vitaly/goenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Env

Example

See

Generate from env file

Install:

go get -u github.com/l-vitaly/goenv/cmd/envgen

To generate a config based on the environment variable file, run the following command:

envgen <env_file> <prefix>

  • env_file - environment variable file
  • prefix - this value will be removed from the field names of the structure and constants

You can also group the fields in the structure by separating them with __ characters. For example, if the name of the environment variable is DB__CONN_SRT, then the result will be like this:

type Config {
  Db {
    ConnSrt string
  }
}