Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Dynaconf | 2,953 | 46 | 139 | 18 hours ago | 80 | June 06, 2022 | 111 | mit | Python | |
Configuration Management for Python ⚙ | ||||||||||
Node Convict | 2,163 | 1,056 | 446 | 2 months ago | 62 | May 07, 2022 | 66 | other | JavaScript | |
Featureful configuration management library for Node.js | ||||||||||
Envkey | 393 | 12 | 16 | 4 days ago | 75 | November 02, 2022 | 9 | mit | TypeScript | |
End-to-end encrypted configuration and secrets management | ||||||||||
Config | 304 | 1 | 2 months ago | 34 | June 19, 2022 | 2 | mit | Go | ||
A lightweight yet powerful configuration manager for the Go programming language | ||||||||||
Fig | 246 | 8 | 2 months ago | 2 | January 03, 2022 | 4 | apache-2.0 | Go | ||
A minimalist Go configuration library | ||||||||||
Fsconfig | 114 | 2 | 2 years ago | 23 | July 25, 2021 | 3 | unlicense | F# | ||
FsConfig is a F# library for reading configuration data from environment variables and AppSettings with type safety. | ||||||||||
Parse_it | 97 | 1 | 1 | 3 days ago | 102 | July 05, 2022 | 4 | lgpl-3.0 | Python | |
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations. | ||||||||||
Envh | 96 | 6 | 1 | 21 days ago | 9 | May 05, 2022 | mit | Go | ||
Go helpers to manage environment variables | ||||||||||
Envyable | 76 | 125 | 6 | 2 years ago | 8 | November 08, 2016 | 2 | mit | Ruby | |
The simplest yaml to ENV config loader. | ||||||||||
Ini | 71 | 7 | 2 days ago | 32 | September 15, 2022 | mit | Go | |||
📝 Go INI config management. support multi file load, data override merge. parse ENV variable, parse variable reference. Dotenv file parse and loader. INI配置读取管理,支持多文件加载,数据覆盖合并, 解析ENV变量, 解析变量引用。DotEnv 解析加载 |
GoLobby DotEnv is a lightweight package for loading dot env (.env) files into structs for Go projects
It requires Go v1.16
or newer versions.
To install this package run the following command in the root of your project.
go get github.com/golobby/dotenv
Sample .env
file:
DEBUG=true
APP_NAME=MyApp
APP_PORT=8585
IPS=192.168.0.1,192.168.0.2
IDS=10,11,12,13
DB_NAME=shop
DB_PORT=3306
DB_USER=root
DB_PASS=secret
Sample .go
file:
type Config struct {
Debug bool `env:"DEBUG"`
App struct {
Name string `env:"APP_NAME"`
Port int16 `env:"APP_PORT"`
}
Database struct {
Name string `env:"DB_NAME"`
Port int16 `env:"DB_PORT"`
User string `env:"DB_USER"`
Pass string `env:"DB_PASS"`
}
IPs []string `env:"IPS"`
IDs []int64 `env:"IDS"`
}
config := Config{}
file, err := os.Open(".env")
err = dotenv.NewDecoder(file).Decode(&config)
// Use `config` struct in your app!
Decode()
function gets a pointer of a struct.GoLobby DotEnv uses the GoLobby Cast package to cast environment variables to related struct field types. Here you can see the supported types:
The following snippet shows a valid dot env file.
String = Hello Dot Env # Comment
# Quotes
Quote1="Quoted message!"
Quote2="You can use ' here"
Quote3='You can use " here'
Quote4="You can use # here"
# Booleans
Bool1 = true
Bool2 = 1 # true
Bool3 = false
Bool4 = 0 # false
# Arrays
Ints = 1,2, 3, 4 , 5 # []int{1, 2, 3, 4, 5}
Strings = a,b, c, d , e # []string{"a", "b", "c", "d", "e"}
Floats = 3.14,9.8, 6.9 # []float32{3.14, 9.8, 6.9}
GoLobby DotEnv is released under the MIT License.