woohaha / envUnmarshal-go

A convenient way to read environment variable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Environment Variables Unmarshal Utility for Golang

A convenient way to read environment variable.

Usage:

  1. go get github.com/woohaha/envUnmarshal-go

  2. Define struct

type Param struct {
First  string `env:"first"`
Second string `env:"second"`
Third  string `env:"third"`
}

Note: Type of Fields must be string

  1. Declare an object of the struct
var param *Param
  1. Inject environment variables into object
import env "github.com/woohaha/envUnmarshal-go"
env.Unmarshal(param)
  1. Enjoy
fmt.Println(param.First)

About

A convenient way to read environment variable.

License:MIT License


Languages

Language:Go 100.0%