env

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 5 Imported by: 18

README

env

Go Reference

Access environment of applications safely.

Install

go get github.com/altipla-consulting/env

Contributing

You can make pull requests or create issues in GitHub. Any code you send should be formatted using make gofmt.

License

MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAzureFunction

func IsAzureFunction() bool

IsAzureFunction detects if we are running inside an Azure Function app.

func IsCI

func IsCI() bool

IsCI detects CI environments like Jenkins or GitHub Actions.

func IsCloudRun

func IsCloudRun() bool

IsCloudRun detects if we are running inside a Cloud Run app.

func IsJenkins

func IsJenkins() bool

IsJenkins detects if we are running as a step of a Jenkins build.

func IsKubernetes

func IsKubernetes() bool

IsKubernetes detects if we are running inside a Kubernetes pod.

func IsLocal

func IsLocal() bool

IsLocal returns true if we are running inside a local debug environment instead of a production container. It dependes on Version() working correctly.

func IsProduction added in v0.3.0

func IsProduction() bool

IsProduction returns true if we are running inside a production environment. It depends on Version() working correctly.

func MustRead

func MustRead(name string) string

MustRead asserts an env variable exists and it is not empty. It reads its value. If the value starts with "base64://" it will be decoded as well before returning.

func MustReadJSON added in v0.1.0

func MustReadJSON(name string, dest any)

MustReadJSON asserts an env variable exists and it is not empty. It reads its value and unmarshals it into the given destination. If the value starts with "base64://" it will be decoded as well before returning.

func OptionalRead added in v0.2.0

func OptionalRead(name string) string

OptionalRead reads an env variable if it exists and it is not empty. It returns the value. If the value starts with "base64://" it will be decoded as well before returning.

func ServiceName

func ServiceName() string

ServiceName returns the version of the application from the environment-dependent variables or the hostname if none is available.

func Version

func Version() string

Version returns the application version. In supported environment it may extract the info from files or environment variables. Otherwise it will use the env variable VERSION that should be set manually to the desired value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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