env

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 7 Imported by: 1

README

ENV - a tiny .env wrapper

this is probably not much to use to anybody else but feel free to do whatever you want with it

import "go.atrox.dev/env"
Notes:
  • .env file is automatically loaded, if there is no .env file this wrapper does not care - no error is thrown
  • APP_ENV must be set to the apps current environment (development/staging/production, ...)
  • get environment variables with Get(key) and GetDefault(key, default)
  • check if production with IsProduction() or development with IsDevelopment()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppEnvironment

func AppEnvironment() string

AppEnvironment returns the name of the current environment the app is in

func Get

func Get(key string) string

Get returns the value of the specified environment variable

func GetDefault

func GetDefault(key, defaultValue string) string

GetDefault returns the value of the specified environment variable If the variable is not defined or is empty, return the default value

func GoVersion added in v1.2.0

func GoVersion() string

GoVersion returns the Go version used to build the application

func IsDevelopment

func IsDevelopment() bool

IsDevelopment returns true if the current environment is development

func IsProduction

func IsProduction() bool

IsProduction returns if the current environment is production

func Parse added in v1.2.0

func Parse(v any) error

Parse parses environment variables into the provided struct. See github.com/caarlos0/env for tag documentation.

Additionally supports buildinfo tags for build information:

type Config struct {
    GoVersion string    `buildinfo:"goversion"`
    Revision  string    `buildinfo:"revision"`
    Short     string    `buildinfo:"revisionshort"`
    Time      time.Time `buildinfo:"revisiontime"`
    Modified  bool      `buildinfo:"revisionmodified"`
}

func Revision added in v1.2.0

func Revision() string

Revision returns the full VCS revision used to build the application

func RevisionModified added in v1.2.0

func RevisionModified() bool

RevisionModified returns true if there were uncommitted changes when the application was built

func RevisionShort added in v1.2.0

func RevisionShort() string

RevisionShort returns the short VCS revision used to build the application

func RevisionTime added in v1.2.0

func RevisionTime() time.Time

RevisionTime returns the VCS revision time used to build the application

Types

This section is empty.

Jump to

Keyboard shortcuts

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