detects

package
v1.6.25 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 7 Imported by: 6

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

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 InK8s

func InK8s() bool

InK8s detects if the service is running under k8s environment.

func InK8sYN

func InK8sYN() bool

InK8sYN is yet another DetectInK8s impl

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

func InTestingT(args []string) bool

InTestingT detects whether is running under 'go test' mode

func InTracing added in v1.6.3

func InTracing() bool

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.

Jump to

Keyboard shortcuts

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