osext

package
v0.0.0-...-d430ac9 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 15

Documentation

Overview

Package osext contains extensions to the standard library package "os".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetenvBool

func GetenvBool(key string) bool

GetenvBool returns true if and only if the environment variable with the given key exists and contains a string that strconv.ParseBool() recognizes as true. Non-existent or malformed values will be coerced into "false".

This method is commonly used for optional behavior flags, e.g. to activate debug logging.

func GetenvOrDefault

func GetenvOrDefault(key, defaultValue string) string

GetenvOrDefault returns os.Getenv(key), except that if the environment variable is not set, the given default value will be returned instead.

func MustGetenv

func MustGetenv(key string) string

NeedGetenv returns os.Getenv(key), or panics if the environment variable is not set.

func NeedGetenv

func NeedGetenv(key string) (string, error)

NeedGetenv returns os.Getenv(key), or an error if the environment variable is not set.

Types

type MissingEnvError

type MissingEnvError struct {
	Key string
}

MissingEnvError is an error that occurs when an required environment variable was not present.

func (MissingEnvError) Error

func (e MissingEnvError) Error() string

Error implements the builtin/error interface.

Jump to

Keyboard shortcuts

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