env

package
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 9 Imported by: 0

README

env

全局公用环境变量

Documentation

Index

Constants

View Source
const (
	NextEnvPrefix        = "NEXT_"
	HostIDKey            = "HOST_ID"
	HostnameKey          = "HOST_NAME"
	WorkPathKey          = "WORK_PATH"
	DeployColorKey       = "DEPLOY_COLOR"
	DeployEnvironmentKey = "DEPLOY_ENV"
)
View Source
const (
	Dev        = "dev"        // 开发环境
	Test       = "testing"    // 环境环境
	Staging    = "staging"    // 预发环境
	Production = "production" // 线上环境
)

Variables

This section is empty.

Functions

func AppVersion

func AppVersion() string

AppVersion get app version

func BuildTime

func BuildTime() string

BuildTime get buildTime

func DeployColor

func DeployColor() string

DeployColor is the identification of different experimental group in one caster cluster.

func DeployEnvironment

func DeployEnvironment() string

DeployEnvironment get deploy environment

func Env added in v1.0.19

func Env(name string) string

Env returns the value of the given environment variable.

func EnvInt added in v1.0.19

func EnvInt(name string) (int, bool)

EnvInt returns an int value of the given environment variable.

func GetEnvKey

func GetEnvKey(env string) string

GetEnvKey get env key: NEXT_{env}

func GitCommit

func GitCommit() string

GitCommit git commit

func GitTag

func GitTag() string

GitTag git tag

func GoVersion

func GoVersion() string

GoVersion get go version

func HostID

func HostID() int

HostID get host id

func Hostname

func Hostname() string

Hostname get hostname

func IntEnvOr

func IntEnvOr(key string, defaultValue int) int

IntEnvOr returns the int value of the environment variable with name key if it exists and the value is an int. Otherwise, defaultValue is returned.

func IsDev

func IsDev() bool

IsDev is dev environment

func IsProduction

func IsProduction() bool

IsProduction is production environment

func IsStaging added in v1.0.5

func IsStaging() bool

IsStaging is staging environment

func IsTest

func IsTest() bool

IsTest is test environment

func StartTime

func StartTime() string

StartTime get start time

func StringEnvOr

func StringEnvOr(key string, defaultValue string) string

StringEnvOr returns the string value of the environment variable with name key if it exists and the value is an string. Otherwise, defaultValue is returned.

func WorkDir

func WorkDir() string

WorkDir work path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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