environment

package
v2.0.0-...-4b7107c Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 6 Imported by: 0

README

environment

Description

A reusable library of code for working with environment variables safely.

Usage

We create methods which will fetch a given environment variable and return the appropriate datatype. Get will get the type or return the type's default value ("", 0, false, etc.)

  • environment.GetString(name string) (string, error)

  • environment.GetStringp(name *string) (string, error)

  • environment.RequireString(name string) (string, error)

  • environment.RequireStringp(name *string) (string, error)

  • environemnt.SanitizeString(name string, pattern string) (string, error)

  • environemnt.SanitizeStringp(name *string, pattern *string) (string, error)

  • environment.GetInt(name string) (int, error)

  • environment.GetIntp(name *string) (int, error)

  • environment.RequireInt(name string) (int, error)

  • environment.RequireIntp(name *string) (int, error)

  • environemnt.SanitizeInt(name string, min int, max int) (int, error)

  • environemnt.SanitizeIntp(name *string, min int, max int) (int, error)

  • environment.GetFloat(name string) (float64, error)

  • environment.GetFloatp(name *string) (float64, error)

  • environment.RequireFloat(name string) (float64, error)

  • environment.RequireFloatp(name *string) (float64, error)

  • environemnt.SanitizeFloat(name string, min float64, max float64) (float64, error)

  • environemnt.SanitizeFloatp(name *string, min float64, max float64) (float64, error)

  • environment.GetBool(name string) (bool, error)

  • environment.GetBoolp(name *string) (bool, error)

  • environment.RequireBool(name string) (bool, error)

  • environment.RequireBoolp(name *string) (bool, error)

  • environment.SanitizeBool(name string) (bool, error)

  • environment.SanitizeBoolp(name *string) (bool, error)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBool

func GetBool(name string) (bool, error)

GetBool - Return the boolean value of an environment variable.

func GetBoolp

func GetBoolp(name *string) (r bool, e error)

GetBoolp - Return the boolean value of an environment variable.

func GetFloat

func GetFloat(name string) (r float64, e error)

GetFloat - Return the floating-point value of a given environment variable

func GetFloatp

func GetFloatp(name *string) (r float64, e error)

GetFloatp - Return the floating-point value of a given environment variable

func GetInt

func GetInt(name string) (r int, e error)

GetInt - Return the int value of a given environment variable

func GetIntp

func GetIntp(name *string) (result int, err error)

GetIntp - Return the int value of a given environment variable

func GetString

func GetString(name string) (r string, e error)

GetString - Return the int value of a given environment variable

func GetStringp

func GetStringp(name *string) (r string, e error)

GetStringp - Return the int value of a given environment variable

func RequireBool

func RequireBool(name string) (bool, error)

RequireBool - Return the boolean value of an environment variable (returning error if empty).

func RequireBoolp

func RequireBoolp(name *string) (r bool, e error)

RequireBoolp - Return the boolean value of an environment variable (returning error if empty).

func RequireFloat

func RequireFloat(name string) (float64, error)

RequireFloat - Return the Float value of an environment variable (returning error if empty).

func RequireFloatp

func RequireFloatp(name *string) (r float64, e error)

RequireFloatp - Return the Float value of an environment variable (returning error if empty).

func RequireInt

func RequireInt(name string) (r int, e error)

RequireInt - Return the int value of a given environment variable (return error if not set)

func RequireIntp

func RequireIntp(name *string) (r int, e error)

RequireIntp - Return the int value of a given environment variable (return error if not set)

func RequireString

func RequireString(name string) (r string, e error)

RequireString - Return the string value of a given environment variable (return error if not set)

func RequireStringp

func RequireStringp(name *string) (r string, e error)

RequireStringp - Return the string value of a given environment variable (return error if not set)

func SanitizeBool

func SanitizeBool(name string) (r bool, e error)

SanitizeBool - Return the sanitized boolean value of a given environment variable name.

func SanitizeBoolp

func SanitizeBoolp(name *string) (r bool, e error)

SanitizeBoolp - Return the sanitized boolean value of a given environment variable name.

func SanitizeFloat

func SanitizeFloat(name string, min float64, max float64) (float64, error)

SanitizeFloat - get the float env var and bounds check the value

func SanitizeFloatp

func SanitizeFloatp(name *string, min float64, max float64) (float64, error)

SanitizeFloatp - get the float env var and bounds check the value

func SanitizeInt

func SanitizeInt(name string, min, max int) (int, error)

SanitizeInt - return sanitized integer env var

func SanitizeIntp

func SanitizeIntp(name *string, min, max int) (int, error)

SanitizeIntp - return sanitized environment variable (sanitized)

func SanitizeString

func SanitizeString(name, pattern string) (string, error)

SanitizeString - return the string env var (sanitized by regex pattern)

func SanitizeStringp

func SanitizeStringp(name, pattern *string) (string, error)

SanitizeStringp - return the string env var (sanitized by regex pattern)

func SetAny

func SetAny(name string, value any) error

SetAny - Set an environment variable of any type

func SetAnyp

func SetAnyp(name *string, value *any) error

SetAnyp - Set an environment variable of any type

func SetBool

func SetBool(name string, value bool) error

SetBool - Set Environment variable value

func SetBoolp

func SetBoolp(name *string, value bool) error

SetBoolp - Set Environment variable value (pointer)

func SetFloat

func SetFloat(name string, value float64) error

SetFloat - Set Environment variable value

func SetFloatp

func SetFloatp(name *string, value float64) error

SetFloatp - Set Environment variable value (pointer)

func SetInt

func SetInt(name string, value int) error

SetInt - Set Environment variable value

func SetIntp

func SetIntp(name *string, value int) error

SetIntp - Set Environment variable value (pointer)

func SetString

func SetString(name string, value string) error

SetString - SetString Environment variable value (pointer)

func SetStringp

func SetStringp(name *string, value *string) error

SetStringp - Set Environment variable value (pointer)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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