KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
env
★ 17
Open GitHub ↗
Set the values of a struct with env variables
Download README (.md)
Explore Similar Repositories
running-death-overdrive
:
Listen to Running Death's album Overdrive
p5.js-education
:
p5 education working group repo
LightFirewall
:
Lightweight firewall built for NodeJs.
osx-mac-menubar-app
:
Menubar application for Mac
ocaml-gammu
:
Cell phone and SIM card access.
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
env
?
Download (.md)
## env/decoder Decode Structs from the Environment [](https://godoc.org/github.com/jpoz/env/decoder) ```go package main import ( "fmt" "github.com/jpoz/env/decoder" ) type Config struct { Env string `env:"ENV"` Addr string `expand:"$HOST:$PORT"` Workers int `env:"WORKERS"` } func main() { config := Config{ Env: "dev", // default if ENV is not set } decoder.Decode(&config) fmt.Printf("%s running in %s with %d workers", config.Addr, config.Env, config.Workers) } ``` ``` $ HOST=hello PORT=9000 WORKERS=123 go run example.go hello:9000 running in dev with 123 workers ```