Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codingconcepts/env
Tag-based environment configuration for structs
https://github.com/codingconcepts/env
Last synced: about 1 month ago
JSON representation
Tag-based environment configuration for structs
- Host: GitHub
- URL: https://github.com/codingconcepts/env
- Owner: codingconcepts
- License: mit
- Created: 2017-06-14T20:01:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-21T22:01:19.000Z (almost 4 years ago)
- Last Synced: 2024-01-30T04:04:58.180Z (4 months ago)
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 107
- Watchers: 2
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go-extra - env - based environment configuration for structs|93|9|1|2017-06-14T20:01:55Z|2020-08-21T22:01:19Z| (Build Automation / Standard CLI)
- awesome-go-cn - env
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go-projects - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - based environment configuration for structs. | - | - | - | (Command Line / Standard CLI)
- awesome-go-with-framework - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go-cn - env
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - 针对结构的基于标记的环境配置。 (<span id="命令行-command-line">命令行 Command Line</span> / 标准CLI)
- awesome-go. - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go-with-stars - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-Char - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- repo-1316-awesome-go-cn - env
- repo-1211-awesome-go-cn - env
- awesome-reader - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- Go-awesome - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go-cn - env
- awesome-go-cn - env - based environment configuration for structs.) (命令行 / Standard CLI)
- go-awesome-cn-star - env
- awesome-go-handwritten - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go2 - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. - :arrow_down:5 - :star:18 (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go-stars - env(stars: 111) - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go-cn - env
- awesome-go-zh - env
- awesome-go - env - Tag-based environment configuration for structs - ★ 34 (Command Line)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
- awesome-go - env - Tag-based environment configuration for structs. (Command Line / Standard CLI)
README
# env
Tag-based environment configuration for structs.[![Godoc](https://godoc.org/github.com/codingconcepts/env?status.svg)](https://godoc.org/github.com/codingconcepts/env)
[![Build Status](https://travis-ci.org/codingconcepts/env.svg?branch=master)](https://travis-ci.org/codingconcepts/env)
[![Go Report Card](https://goreportcard.com/badge/github.com/codingconcepts/env)](https://goreportcard.com/report/github.com/codingconcepts/env)## Installation
``` bash
$ go get -u github.com/codingconcepts/env
```## Usage
``` go
package mainimport (
"fmt"
"log"
"time""github.com/codingconcepts/env"
)type config struct {
Secret []byte `env:"SECRET" required:"true"`
Region string `env:"REGION"`
Port int `env:"PORT" required:"true"`
Peers []string `env:"PEERS"` // you can use `delimiter` tag to specify separator, for example `delimiter:" "`
ConnectionTimeout time.Duration `env:"TIMEOUT" default:"10s"`
}func main() {
c := config{}
if err := env.Set(&c); err != nil {
log.Fatal(err)
}...
}
`````` bash
$ ID=1 SECRET=shh PORT=1234 PEERS=localhost:1235,localhost:1236 TIMEOUT=5s go run main.go
```## Supported field types
- `bool` and `[]bool`
- `string` and `[]string`
- `[]byte`
- `int`, `int8`, `int16`, `int32`, `int64`, `[]int`, `[]int8`, `[]int16`, `[]int32`, and `[]int64`
- `uint`, `uint8`, `uint16`, `uint32`, `uint64`, `[]uint`, `[]uint8`, `[]uint16`, `[]uint32`, and `[]uint64`
- `float32`, `float64`, `[]float32`, and `[]float64`
- `time.Duration` and `[]time.Duration`