env

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

README

env SDK

服务环境配置

为了更好地实现代码一致性,区分开发,测试,生成环境。 我们引入加入DEV(开发环境) UAT(测试环境) PRO(开发环境) ,通过环境变量实现 。

环境变量列表
	export DEPLOYENV=dev
	export HOSTNAME=user
	export APPID=app
名称 说明
DEPLOYENV dev:开发环境 pre:预发布 online:测试
HOSTNAME 服务名
APPID 项目ID
配置

具体见Config结构体,通过Init函数实现初始化

example
import (
	"fmt"
	"github.com/zdao-pro/sky_blue/pkg/env"
)
// main.go
func main() {
    a := env.GetAppID()
	fmt.Println(a)

	e := env.GetEnv()
	fmt.Println(e)

	h := env.GetHostname()
	fmt.Println(h)
}

Documentation

Index

Constants

View Source
const (
	DeployEnvDev    = "dev"
	DeployEnvPre    = "pre"
	DeployEnvOnline = "online"
)

env configuration.

Variables

View Source
var (
	// Hostname machine hostname.
	Hostname string
	// AppID is global unique application id, register by service tree.
	// such as main.arch.disocvery.
	AppID string
	// DeployEnv deploy env where app at.
	DeployEnv string
	// Color is the identification of different experimental group in one caster cluster.
	Color string
	// DiscoveryNodes is seed nodes.
	DiscoveryNodes string
	// Region available region where app at.
	Region string
	// Zone available zone where app at.
	Zone string
)

Functions

func GetAppID

func GetAppID() string

GetAppID 获取应用ID

func GetEnv

func GetEnv() string

GetEnv 获取应用环境变量

func GetHostname

func GetHostname() string

GetHostname 获取应用主机名

func IsDev

func IsDev() bool

IsDev 是否为开发环境

func IsOnline

func IsOnline() bool

IsOnline 是否为生产环境

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL