Netflix / Go Env
Licence: apache-2.0
a golang library to manage environment variables
Stars: ✭ 247
Labels
Projects that are alternatives of or similar to Go Env
Environ Config
Python Application Configuration With Environment Variables
Stars: ✭ 210 (-14.98%)
Mutual labels: environment-variables
Envy
Envy automatically exposes environment variables for all of your Go flags
Stars: ✭ 150 (-39.27%)
Mutual labels: environment-variables
Aconfig
Simple, useful and opinionated config loader.
Stars: ✭ 187 (-24.29%)
Mutual labels: environment-variables
Dotnet Env
A .NET library to load environment variables from .env files
Stars: ✭ 195 (-21.05%)
Mutual labels: environment-variables
Python Decouple
Strict separation of config from code.
Stars: ✭ 1,982 (+702.43%)
Mutual labels: environment-variables
Cleanenv
✨Clean and minimalistic environment configuration reader for Golang
Stars: ✭ 245 (-0.81%)
Mutual labels: environment-variables
Gotenv
Load environment variables from `.env` or `io.Reader` in Go.
Stars: ✭ 193 (-21.86%)
Mutual labels: environment-variables
Heroku Config
[Utility] Push and pull heroku environment variables to your local env
Stars: ✭ 207 (-16.19%)
Mutual labels: environment-variables
Env
Simple lib to parse environment variables to structs
Stars: ✭ 2,164 (+776.11%)
Mutual labels: environment-variables
Envdecode
Go package for populating structs from environment variables using struct tags
Stars: ✭ 174 (-29.55%)
Mutual labels: environment-variables
Env Var
Verification, sanitization, and type coercion for environment variables in Node.js
Stars: ✭ 201 (-18.62%)
Mutual labels: environment-variables
Phpdotenv
Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
Stars: ✭ 11,648 (+4615.79%)
Mutual labels: environment-variables
Werdlists
⌨️ Wordlists, Dictionaries and Other Data Sets for Writing Software Security Test Cases
Stars: ✭ 216 (-12.55%)
Mutual labels: environment-variables
Node Convict
Featureful configuration management library for Node.js
Stars: ✭ 1,855 (+651.01%)
Mutual labels: environment-variables
React Native Dotenv
Load react native environment variables using import statements for multiple env files.
Stars: ✭ 190 (-23.08%)
Mutual labels: environment-variables
Konfig
Simple config properties API for Kotlin
Stars: ✭ 249 (+0.81%)
Mutual labels: environment-variables
Now Env
Use `now.json` environment variables while developing
Stars: ✭ 219 (-11.34%)
Mutual labels: environment-variables
Config
🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP
Stars: ✭ 203 (-17.81%)
Mutual labels: environment-variables
go-env
Package env provides an env
struct field tag to marshal and unmarshal environment variables.
Usage
package main
import (
"log"
"time"
env "github.com/Netflix/go-env"
)
type Environment struct {
Home string `env:"HOME"`
Jenkins struct {
BuildId *string `env:"BUILD_ID"`
BuildNumber int `env:"BUILD_NUMBER"`
Ci bool `env:"CI"`
}
Node struct {
ConfigCache *string `env:"npm_config_cache,NPM_CONFIG_CACHE"`
}
Extras env.EnvSet
Duration time.Duration `env:"TYPE_DURATION"`
DefaultValue string `env:"MISSING_VAR,default=default_value"`
RequiredValue string `env:"IM_REQUIRED,required=true"`
}
func main() {
var environment Environment
es, err := env.UnmarshalFromEnviron(&environment)
if err != nil {
log.Fatal(err)
}
// Remaining environment variables.
environment.Extras = es
// ...
es, err = env.Marshal(environment)
if err != nil {
log.Fatal(err)
}
home := "/tmp/edgarl"
cs := env.ChangeSet{
"HOME": &home,
"BUILD_ID": nil,
"BUILD_NUMBER": nil,
}
es.Apply(cs)
environment = Environment{}
err = env.Unmarshal(es, &environment)
if err != nil {
log.Fatal(err)
}
environment.Extras = es
}
Custom Marshaler/Unmarshaler
There is limited support for dictating how a field should be marshaled or unmarshaled. The following example shows how you could marshal/unmarshal from JSON
import (
"encoding/json"
"fmt"
"log"
env "github.com/Netflix/go-env"
)
type SomeData struct {
SomeField int `json:"someField"`
}
func (s *SomeData) UnmarshalEnvironmentValue(data string) error {
var tmp SomeData
err := json.Unmarshal([]byte(data), &tmp)
if err != nil {
return err
}
*s = tmp
return nil
}
func (s SomeData) MarshalEnvironmentValue() (string, error) {
bytes, err := json.Marshal(s)
if err != nil {
return "", err
}
return string(bytes), nil
}
type Config struct {
SomeData *SomeData `env:"SOME_DATA"`
}
func main() {
var cfg Config
_, err := env.UnmarshalFromEnviron(&cfg)
if err != nil {
log.Fatal(err)
}
if cfg.SomeData != nil && cfg.SomeData.SomeField == 42 {
fmt.Println("Got 42!")
} else {
fmt.Printf("Got nil or some other value: %v\n", cfg.SomeData)
}
es, err = env.Marshal(cfg)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Got the following: %+v\n", es)
}
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].