All Projects → golobby → env

golobby / env

Licence: MIT License
A lightweight package for loading OS environment variables into structs for Go projects

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to env

goodconf
Transparently load variables from environment or JSON/YAML file.
Stars: ✭ 80 (+233.33%)
Mutual labels:  config, configuration, environment-variables, env
read-env
🔧 Transform environment variables into JSON object with sanitized values.
Stars: ✭ 60 (+150%)
Mutual labels:  config, configuration, environment-variables, env
Node Convict
Featureful configuration management library for Node.js
Stars: ✭ 1,855 (+7629.17%)
Mutual labels:  config, configuration, environment-variables, env
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+258.33%)
Mutual labels:  config, configuration, environment-variables
Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (+8575%)
Mutual labels:  config, configuration, environment-variables
Config
A lightweight yet powerful config package for Go projects
Stars: ✭ 126 (+425%)
Mutual labels:  config, configuration, environment-variables
Config
🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP
Stars: ✭ 203 (+745.83%)
Mutual labels:  config, configuration, environment-variables
Environ Config
Python Application Configuration With Environment Variables
Stars: ✭ 210 (+775%)
Mutual labels:  config, configuration, environment-variables
Aconfig
Simple, useful and opinionated config loader.
Stars: ✭ 187 (+679.17%)
Mutual labels:  config, configuration, environment-variables
ini
📝 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 解析加载
Stars: ✭ 72 (+200%)
Mutual labels:  config, environment-variables, env
superconfig
Access environment variables. Also includes presence validation, type coercion and default values.
Stars: ✭ 33 (+37.5%)
Mutual labels:  config, configuration, environment-variables
Env
Simple lib to parse environment variables to structs
Stars: ✭ 2,164 (+8916.67%)
Mutual labels:  config, configuration, environment-variables
environment
🌳 Environment variable configuration for Node.js made easy.
Stars: ✭ 12 (-50%)
Mutual labels:  config, configuration, env
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-16.67%)
Mutual labels:  config, configuration, environment-variables
sitri
Sitri - powerful settings & configs for python
Stars: ✭ 20 (-16.67%)
Mutual labels:  config, configuration, environment-variables
exenv
Exenv makes loading environment variables from external sources easy.
Stars: ✭ 35 (+45.83%)
Mutual labels:  config, environment-variables, env
salak.rs
A multi layered configuration loader and zero-boilerplate configuration parser.
Stars: ✭ 27 (+12.5%)
Mutual labels:  config, configuration, env
ngx-env
Easily inject environment variables into your Angular applications
Stars: ✭ 73 (+204.17%)
Mutual labels:  configuration, environment-variables
fuck-env
Fuck environment variables everywhere
Stars: ✭ 14 (-41.67%)
Mutual labels:  environment-variables, env
spdlog setup
spdlog setup initialization via file configuration for convenience.
Stars: ✭ 68 (+183.33%)
Mutual labels:  config, configuration

GoDoc CI CodeQL Go Report Card Coverage Status

Env

GoLobby Env is a lightweight package for loading OS environment variables into structs for Go projects.

Documentation

Supported Versions

It requires Go v1.11 or newer versions.

Installation

To install this package run the following command in the root of your project

go get github.com/golobby/env/v2

Usage Example

The following example demonstrates how to use GoLobby Env package.

type Config struct {
    Debug bool      `env:"DEBUG"` // Possible Values: "true", "false", "1", "0"
    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` // Possible Value: "192.168.0.1, 192.168.0.2"
    IDs []int32  `env:IDS` // Possible Value: "10, 11, 12"
}

config := Config{}
err := env.Feed(&config)

// Use `config` struct in your app!

Usage Tips

  • The Feed() function gets a pointer of a struct.
  • It ignores empty OS environment variables.
  • It supports nested structs and struct pointers.

Field Types

GoLobby Env uses the GoLobby Cast package to cast OS environment variables to related struct field types. Here you can see the supported types:

https://github.com/golobby/cast#supported-types

See Also

  • GoLobby/Config: A lightweight yet powerful configuration management for Go projects
  • GoLobby/DotEnv: A lightweight package for loading dot env (.env) files into structs for Go projects

License

GoLobby Env is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].