项目作者: PxyUp

项目描述 :
Small lib for getting and setting default value for ENV var
高级语言: Go
项目地址: git://github.com/PxyUp/default-env.git
创建时间: 2018-11-21T19:15:11Z
项目社区:https://github.com/PxyUp/default-env

开源协议:MIT License

下载


Default env

Small lib for getting default value for ENV var

Order of reading var:

  1. ENV
  2. Yml file

Variables reading only one time when you call GetInstance

Use and Example

  1. go get github.com/PxyUp/default-env
  1. import (
  2. "github.com/PxyUp/default-env"
  3. )
  4. inst := default_env.GetInstance("env.yml") // ths is singleton and read only on time file and ENV var
  5. inst.Get("BACKEND_URL") // "http://main.go"
  6. inst.Get("FRONT_URL") // "http://frontend.go"
  7. inst.Get("SITE_URL") // "http://site.com"
  1. export SITE_URL=http://site.com

env.yml:

  1. env_var:
  2. BACKEND_URL: http://main.go
  3. FRONT_URL: http://frontend.go