env

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MIT Imports: 8 Imported by: 4

Documentation

Overview

Package env provides functions get environment variable infos. get environment variable infos. usage:

	env.Info()
 env.IsLocal()
	env.IsDev()
	env.IsProd()
	env.IsTest()
 env.IsDocker()
 env.IsK8s()
 env.AppRootPath()
 env.ConfigFileName()
 env.ConfigFilePath()
 env.ConfigFilePathAbs()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppRootPath

func AppRootPath() string

AppRootPath return the context path

func GetContextVal

func GetContextVal(key any) any

GetContextVal get env info's context value by key

func GetInfo

func GetInfo() *info

GetInfo returns the environment information.

func Init

func Init() error

Init initializes the environment information.

func IsDev

func IsDev() bool

IsDev is development environment

func IsDocker

func IsDocker() bool

IsDocker is docker environment

func IsK8s

func IsK8s() bool

IsK8s is k8s environment

func IsLocal

func IsLocal() bool

IsLocal is local environment

func IsProd

func IsProd() bool

IsProd is production environment

func IsTest

func IsTest() bool

IsTest is test environment

func SetAppRootPath added in v1.6.0

func SetAppRootPath(path string)

SetAppRootPath set the app root path

func SetContextVal

func SetContextVal(key any, value any)

SetContextVal set env info's context value

func Type2String

func Type2String(t Env) string

Type2String returns the string representation of the given environment type.

Types

type Env

type Env int8

Env custom environment type

const (
	// Unknown environment
	Unknown Env = iota
	// Local environment
	Local
	// Dev development environment
	Dev
	// Test environment
	Test
	// Prod production environment
	Prod
	// Docker docker environment
	Docker
	// K8s k8s environment
	K8s
)

Jump to

Keyboard shortcuts

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