Documentation ¶
Overview ¶
Package detects collects all detector, buildtags, environment settings in one place.
By using detects package, you have no needs to call `buildtags`, `states` and other similar packages.
Index ¶
- func Env() states.CmdrMinimal
- func GetDebugLevel() int
- func GetNoColorLevel() int
- func GetQuietLevel() int
- func GetTraceLevel() int
- func GetVerboseLevel() int
- func InDebugging() bool
- func InDevelopingTime() (status bool)
- func InDocker() bool
- func InDockerEnvSimple() (status bool)
- func InIstio() bool
- func InK8s() bool
- func InK8sYN() bool
- func InTesting() bool
- func InTestingT(args []string) bool
- func InTracing() bool
- func IsDebugBuild() bool
- func IsDebugModeEnabled() bool
- func IsDebuggerAttached() bool
- func IsDockerBuild() bool
- func IsIstioBuild() bool
- func IsK8sBuild() bool
- func IsNoColorModeEnabled() bool
- func IsQuietModeEnabled() bool
- func IsTraceModeEnabled() bool
- func IsTracingEnabled() bool
- func IsVerboseBuild() bool
- func IsVerboseModeEnabled() bool
- func States() states.CmdrMinimal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Env ¶ added in v1.6.15
func Env() states.CmdrMinimal
func GetDebugLevel ¶ added in v1.6.15
func GetDebugLevel() int
func GetNoColorLevel ¶ added in v1.6.15
func GetNoColorLevel() int
func GetQuietLevel ¶ added in v1.6.15
func GetQuietLevel() int
func GetTraceLevel ¶ added in v1.6.15
func GetTraceLevel() int
func GetVerboseLevel ¶ added in v1.6.15
func GetVerboseLevel() int
func InDebugging ¶ added in v1.6.3
func InDebugging() bool
InDebugging return the status if cmdr was built with debug mode / or the app running under a debugger attached.
To enable the debugger attached mode for cmdr, run `go build` with `-tags=delve` options. eg:
go run -tags=delve ./cli go build -tags=delve -o my-app ./cli
For Goland, you can enable this under 'Run/Debug Configurations', by adding the following into 'Go tool arguments:'
-tags=delve
InDebugging() is a synonym to IsDebuggerAttached().
NOTE that `isdelve` algor is from https://stackoverflow.com/questions/47879070/how-can-i-see-if-the-goland-debugger-is-running-in-the-program
noinspection GoBoolExpressions
func InDevelopingTime ¶ added in v1.6.3
func InDevelopingTime() (status bool)
InDevelopingTime detects whether is in developing time.
If the main program has been built as an executable binary, we would assume which is not in developing time.
If log.GetDebugMode() is true, that's in developing time too.
func InDocker ¶
func InDocker() bool
InDocker detects if the service is running under docker environment.
InDocker test these two conditions: 1. find if `/.dockerenv` exists or not. 2. `docker` in buildtags
func InDockerEnvSimple ¶ added in v1.6.3
func InDockerEnvSimple() (status bool)
InDockerEnvSimple detects whether is running within docker container environment.
InDockerEnvSimple finds if `/.dockerenv` exists or not.
func InIstio ¶
func InIstio() bool
InIstio detects if the service is running under istio injected.
IMPORTANT ¶
To make this detector work properly, you must mount a DownwordAPI volume to your container/pod. See also: https://kubernetes.io/en/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/
func InTesting ¶ added in v1.6.3
func InTesting() bool
InTesting detects whether is running under go test mode
func InTestingT ¶ added in v1.6.5
InTestingT detects whether is running under 'go test' mode
func IsDebugBuild ¶ added in v1.6.15
func IsDebugBuild() bool
func IsDebugModeEnabled ¶ added in v1.6.15
func IsDebugModeEnabled() bool
func IsDebuggerAttached ¶ added in v1.6.3
func IsDebuggerAttached() bool
IsDebuggerAttached return the status if cmdr was built with debug mode / or the app running under a debugger attached.
To enable the debugger attached mode for cmdr, run `go build` with `-tags=delve` options. eg:
go run -tags=delve ./cli go build -tags=delve -o my-app ./cli
For Goland, you can enable this under 'Run/Debug Configurations', by adding the following into 'Go tool arguments:'
-tags=delve
IsDebuggerAttached() is a synonym to InDebugging().
NOTE that `isdelve` algor is from https://stackoverflow.com/questions/47879070/how-can-i-see-if-the-goland-debugger-is-running-in-the-program
noinspection GoBoolExpressions
func IsDockerBuild ¶ added in v1.6.15
func IsDockerBuild() bool
func IsIstioBuild ¶ added in v1.6.15
func IsIstioBuild() bool
func IsK8sBuild ¶ added in v1.6.15
func IsK8sBuild() bool
func IsNoColorModeEnabled ¶ added in v1.6.15
func IsNoColorModeEnabled() bool
func IsQuietModeEnabled ¶ added in v1.6.15
func IsQuietModeEnabled() bool
func IsTraceModeEnabled ¶ added in v1.6.15
func IsTraceModeEnabled() bool
func IsTracingEnabled ¶ added in v1.6.15
func IsTracingEnabled() bool
func IsVerboseBuild ¶ added in v1.6.15
func IsVerboseBuild() bool
func IsVerboseModeEnabled ¶ added in v1.6.15
func IsVerboseModeEnabled() bool
func States ¶ added in v1.6.15
func States() states.CmdrMinimal
States or Env returns a minimal environment settings for a typical CLI app.
See also states.CmdrMinimal.
Types ¶
This section is empty.