Documentation ¶
Overview ¶
copy of github.com/go-task/task/v3/internal/execext/devnull.go
Package godotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv)
Examples/readme can be found on the github page at https://github.com/joho/godotenv
The TL;DR is that you make a .env file that looks something like
SOME_ENV_VAR=somevalue
and then in your go code you can call
godotenv.Load()
and all the env vars declared in .env will be available through os.Getenv("SOME_ENV_VAR")
Index ¶
- Constants
- Variables
- func AbsPath(cwd string, _path string) string
- func AnyArrayToStringArray(anyArray []any) []string
- func Bool(hint string, v any) (bool, error)
- func BoolArray(hint string, v any) ([]bool, error)
- func BoolArrayP(hint string, v any) []bool
- func BoolMap(hint string, v any) (map[string]bool, error)
- func BoolMapP(hint string, v any) map[string]bool
- func BoolP(hint string, v any) bool
- func BroadcastInterfaces(dump bool) ([]net.Interface, error)
- func BroadcastInterfacesP(dump bool) []net.Interface
- func BroadcastIpWithInterface(intf net.Interface) (net.IP, error)
- func BroadcastIpWithInterfaceP(intf net.Interface) net.IP
- func CopyFile(fs afero.Fs, path string, newPath string) (int64, error)
- func CopyFileP(fs afero.Fs, path string, newPath string) int64
- func CreateLockFile(fs afero.Fs, filename string, data any) (afero.File, error)
- func DeepCopyMap[T any](that map[string]T) map[string]T
- func DefaultEtcHosts() (string, error)
- func DefaultEtcHostsP() string
- func DefaultOutput() io.Writer
- func DirExists(fs afero.Fs, path string) (bool, error)
- func DirExistsP(fs afero.Fs, path string) bool
- func DowncastMap[V any](m map[string]V) map[string]any
- func DownloadBytes(logger Logger, fallbackDir string, fs afero.Fs, url string, ...) (result []byte, err error)
- func DownloadBytesP(logger Logger, fallbackDir string, fs afero.Fs, url string, ...) []byte
- func DownloadText(logger Logger, fallbackDir string, fs afero.Fs, url string, ...) (string, error)
- func DownloadTextP(logger Logger, fallbackDir string, fs afero.Fs, url string, ...) string
- func EnsureDirExists(fs afero.Fs, path string) error
- func EnsureDirExistsP(fs afero.Fs, path string)
- func EnsureFileExists(fs afero.Fs, path string) error
- func EnsureFileExistsP(fs afero.Fs, path string)
- func EnvSubst(input string, env map[string]string) (string, error)
- func EnvSubstP(input string, env map[string]string) string
- func EnvSubstSlice(inputs []string, env map[string]string) ([]string, error)
- func EnvSubstSliceP(inputs []string, env map[string]string) []string
- func EnvironList(overrides map[string]string) ([]string, error)
- func EnvironListP(overrides map[string]string) []string
- func EnvironMap(overrides map[string]string) (map[string]string, error)
- func EnvironMapP(overrides map[string]string) map[string]string
- func ExecEnv(fs afero.Fs, filenames []string, cmd string, cmdArgs []string) error
- func ExecZenity(ctx context.Context, hc interp.HandlerContext, args []string) error
- func Executable() (string, error)
- func ExecutableP() string
- func ExpandHomePath(path string) (string, error)
- func ExpandHomePathP(path string) string
- func ExtractTitle(filePath string) string
- func FallbackFilePath(fallbackDir string, url string) string
- func FileExists(fs afero.Fs, path string) (bool, error)
- func FileExistsP(fs afero.Fs, path string) bool
- func Float(hint string, v any) (float64, error)
- func FloatArray(hint string, v any) ([]float64, error)
- func FloatArrayP(hint string, v any) []float64
- func FloatMap(hint string, v any) (map[string]float64, error)
- func FloatMapP(hint string, v any) map[string]float64
- func FloatP(hint string, v any) float64
- func FromJson(jsonText string, envsubt bool, result any) (err error)
- func FromJsonFile(fs afero.Fs, path string, envsubt bool, result any) error
- func FromJsonFileP(fs afero.Fs, path string, envsubt bool, result any)
- func FromJsonP(jsonText string, envsubt bool, result any)
- func FromYaml(yamlText string, envsubt bool, result any) (err error)
- func FromYamlFile(fs afero.Fs, path string, envsubt bool, result any) error
- func FromYamlFileP(fs afero.Fs, path string, envsubt bool, result any)
- func FromYamlP(yamlText string, envsubt bool, result any)
- func GetMapValue[T any](m map[string]any, key string, devault func() T) T
- func GoshExecHandler(killTimeout time.Duration) interp.ExecHandlerFunc
- func HasFallbackFile(fallbackDir string, fs afero.Fs, url string) (bool, error)
- func Hostname() (string, error)
- func HostnameP() string
- func InputSudoPassword(passwordInput FnInput) string
- func InstrumentSudoCommand(cmd string) string
- func Int(hint string, v any) (int, error)
- func IntArray(hint string, v any) ([]int, error)
- func IntArrayP(hint string, v any) []int
- func IntMap(hint string, v any) (map[string]int, error)
- func IntMapP(hint string, v any) map[string]int
- func IntP(hint string, v any) int
- func IsAsciiSpace(s uint8) bool
- func IsDarwin() bool
- func IsDiscardLogger(logger Logger) bool
- func IsEmptyReflectValue(v reflect.Value) bool
- func IsEmptyValue(v any) bool
- func IsFileProtocol(url string) bool
- func IsLinux() bool
- func IsPrimitiveReflectValue(v reflect.Value) bool
- func IsPrimitiveValue(v any) bool
- func IsRemote(url string) bool
- func IsSudoCommand(cmd string) bool
- func IsTerminal() bool
- func IsWindows() bool
- func JoinedLines(lines ...string) string
- func JoinedLinesAsBytes(lines ...string) []byte
- func ListSuffixedFiles(fs afero.Fs, targetDir string, suffix string, skipEmptyFile bool) (map[string]string, error)
- func ListSuffixedFilesP(fs afero.Fs, targetDir string, suffix string, skipEmptyFile bool) map[string]string
- func LoadEnv(fs afero.Fs, filenames ...string) (err error)
- func LoadEnvScript(fs afero.Fs, vars map[string]string, filename string) (map[string]string, error)
- func LoadEnvScripts(fs afero.Fs, vars map[string]string, filenames ...string) (map[string]string, error)
- func LogMap(logger *plog.Entry, key string, m map[string]any) *plog.Entry
- func LogMapper(logger *plog.Entry, key string, mapper ToMap) *plog.Entry
- func Map(hint string, v any) (map[string]any, error)
- func Map2Struct(src map[string]any, dest any) error
- func Map2StructP(src map[string]any, dest any)
- func MapArray(hint string, v any) ([]map[string]any, error)
- func MapArrayP(hint string, v any) []map[string]any
- func MapFromJson(yamlText string, envsubt bool) (map[string]any, error)
- func MapFromJsonFile(fs afero.Fs, path string, envsubt bool) (map[string]any, error)
- func MapFromJsonFileP(fs afero.Fs, path string, envsubt bool) map[string]any
- func MapFromJsonP(yamlText string, envsubt bool) map[string]any
- func MapFromYaml(yamlText string, envsubt bool) (map[string]any, error)
- func MapFromYamlFile(fs afero.Fs, path string, envsubt bool) (map[string]any, error)
- func MapFromYamlFileP(fs afero.Fs, path string, envsubt bool) map[string]any
- func MapFromYamlP(yamlText string, envsubt bool) map[string]any
- func MapP(hint string, v any) map[string]any
- func MarshalEnv(envMap map[string]string) (string, error)
- func MergeMap[T any](bases ...map[string]T) map[string]T
- func Mkdir(fs afero.Fs, path string) error
- func MkdirP(fs afero.Fs, path string)
- func NameOfKey(key string) string
- func OptionalBool(hint string, key string, m map[string]any, devault bool) (result bool, has bool, err error)
- func OptionalBoolP(hint string, key string, m map[string]any, devault bool) (result bool, has bool)
- func OptionalFloat(hint string, key string, m map[string]any, devault float64) (result float64, has bool, err error)
- func OptionalFloatP(hint string, key string, m map[string]any, devault float64) (result float64, has bool)
- func OptionalInt(hint string, key string, m map[string]any, devault int) (result int, has bool, err error)
- func OptionalIntP(hint string, key string, m map[string]any, devault int) (result int, has bool)
- func OptionalMap(hint string, key string, m map[string]any, defaultresult map[string]any) (result map[string]any, has bool, err error)
- func OptionalMapArray(hint string, key string, m map[string]any, defaultresult []map[string]any) (result []map[string]any, has bool, err error)
- func OptionalMapArrayP(hint string, key string, m map[string]any, defaultresult []map[string]any) (result []map[string]any, has bool)
- func OptionalMapP(hint string, key string, m map[string]any, defaultresult map[string]any) (result map[string]any, has bool)
- func OptionalString(hint string, key string, m map[string]any, devault string) (result string, has bool, err error)
- func OptionalStringArrayValue(hint string, key string, m map[string]any, devault []string) (result []string, has bool, err error)
- func OptionalStringArrayValueP(hint string, key string, m map[string]any, devault []string) (result []string, has bool)
- func OptionalStringP(hint string, key string, m map[string]any, devault string) (result string, has bool)
- func OverloadEnv(fs afero.Fs, filenames ...string) (err error)
- func Pair2Vars(pairs []string) map[string]string
- func ParseEnv(r io.Reader) (envMap map[string]string, err error)
- func ReadBytes(reader io.Reader) ([]byte, error)
- func ReadBytesP(reader io.Reader) []byte
- func ReadEnv(fs afero.Fs, filenames ...string) (envMap map[string]string, err error)
- func ReadFallbackFile(fallbackDir string, fs afero.Fs, url string) (string, []byte, error)
- func ReadFileBytes(fs afero.Fs, path string) ([]byte, error)
- func ReadFileBytesP(fs afero.Fs, path string) []byte
- func ReadFileLines(fs afero.Fs, path string) ([]string, error)
- func ReadFileLinesP(fs afero.Fs, path string) []string
- func ReadFileText(fs afero.Fs, path string) (string, error)
- func ReadFileTextP(fs afero.Fs, path string) string
- func ReadLines(reader io.Reader) []string
- func ReadLockFile(fs afero.Fs, filename string) (int, any, error)
- func ReadText(reader io.Reader) (string, error)
- func ReadTextP(reader io.Reader) string
- func RemoveDir(fs afero.Fs, path string) error
- func RemoveDirP(fs afero.Fs, path string)
- func RemoveFile(fs afero.Fs, path string) error
- func RemoveFileP(fs afero.Fs, path string)
- func Rename(fs afero.Fs, path string, newPath string) error
- func RenameP(fs afero.Fs, path string, newPath string)
- func RenderAsTemplate(tmpl string, data map[string]any) (string, error)
- func RenderAsTemplateArray(tmplArray []string, data map[string]any) ([]string, error)
- func RenderAsTemplateArrayP(tmplArray []string, data map[string]any) []string
- func RenderAsTemplateP(tmpl string, data map[string]any) string
- func RenderWithTemplate(w io.Writer, name string, tmpl string, data map[string]any) error
- func RenderWithTemplateP(w io.Writer, name string, tmpl string, data map[string]any)
- func RequiredBool(hint string, key string, m map[string]any) (bool, error)
- func RequiredBoolP(hint string, key string, m map[string]any) bool
- func RequiredFloat(hint string, key string, m map[string]any) (float64, error)
- func RequiredFloatP(hint string, key string, m map[string]any) float64
- func RequiredInt(hint string, key string, m map[string]any) (int, error)
- func RequiredIntP(hint string, key string, m map[string]any) int
- func RequiredMap(hint string, key string, m map[string]any) (map[string]any, error)
- func RequiredMapArray(hint string, key string, m map[string]any) ([]map[string]any, error)
- func RequiredMapArrayP(hint string, key string, m map[string]any) []map[string]any
- func RequiredMapP(hint string, key string, m map[string]any) map[string]any
- func RequiredString(hint string, key string, m map[string]any) (string, error)
- func RequiredStringP(hint string, key string, m map[string]any) string
- func ResolveBroadcastIp(interfaces []net.Interface, interfaceName string) (net.IP, net.IP, error)
- func ResolveBroadcastIpP(interfaces []net.Interface, interfaceName string) (net.IP, net.IP)
- func RunCommandWithInput(vars map[string]string, dir string, cmd string, args ...string) func(...string) (CommandOutput, error)
- func Set2Strings(set *hashset.Set) []string
- func ShortDescription(url string) string
- func Slice2Map[V any](arr []V, keyFunc func(v V) string) map[string]V
- func Slice2Set[T comparable](arr ...T) *hashset.Set
- func SliceEquals[T comparable](a []T, b []T) bool
- func Stat(fs afero.Fs, path string, ensureExists bool) (os.FileInfo, error)
- func StatP(fs afero.Fs, path string, ensureExists bool) os.FileInfo
- func String(hint string, v any) (string, error)
- func StringArray(hint string, v any) ([]string, error)
- func StringArrayP(hint string, v any) []string
- func StringArrayToAnyArray(stringArray []string) []any
- func StringArrayValue(hint string, key string, m map[string]any) ([]string, error)
- func StringArrayValueP(hint string, key string, m map[string]any) []string
- func StringMap(hint string, v any) (map[string]string, error)
- func StringMapP(hint string, v any) map[string]string
- func StringP(hint string, v any) string
- func StructToMap(src any) map[string]any
- func SubstVars(useGoTemplate bool, m map[string]any, parentVars map[string]any, ...) (map[string]any, error)
- func SubstVarsP(useGoTemplate bool, m map[string]any, parentVars map[string]any, ...) map[string]any
- func SysEnvFileNames(fs afero.Fs, shell string) []string
- func TempFile(fs afero.Fs, pattern string) (string, error)
- func TempFileP(fs afero.Fs, pattern string) string
- func TempTextFile(fs afero.Fs, pattern string, content string) (string, error)
- func TempTextFileP(fs afero.Fs, pattern string, content string) string
- func Text2Lines(text string) []string
- func Text2Vars(text string) map[string]string
- func TextLine2Array(line string) []string
- func ToYaml(hint string, me any) (string, error)
- func ToYamlP(hint string, me any) string
- func UnmarshalEnv(str string) (envMap map[string]string, err error)
- func UserHomeDir() (string, error)
- func UserHomeDirP() string
- func Vars2Pair(vars map[string]string) []string
- func WorkDir(url string, defaultDir string) string
- func WorkingDirectory() (string, error)
- func WorkingDirectoryP() string
- func WriteEnv(fs afero.Fs, envMap map[string]string, filename string) error
- func WriteFallbackFile(fallbackDir string, fs afero.Fs, url string, bytes []byte) (string, error)
- func WriteFile(fs afero.Fs, path string, content []byte) error
- func WriteFileIfNotFound(fs afero.Fs, path string, content []byte) (bool, error)
- func WriteFileIfNotFoundP(fs afero.Fs, path string, content []byte) bool
- func WriteFileLines(fs afero.Fs, path string, lines ...string) error
- func WriteFileLinesP(fs afero.Fs, path string, lines ...string)
- func WriteFileP(fs afero.Fs, path string, content []byte)
- func WriteFileText(fs afero.Fs, path string, content string) error
- func WriteFileTextIfNotFound(fs afero.Fs, path string, content string) (bool, error)
- func WriteFileTextIfNotFoundP(fs afero.Fs, path string, content string) bool
- func WriteFileTextP(fs afero.Fs, path string, content string)
- func ZenityError(ctx context.Context, hc interp.HandlerContext, args []string) error
- func ZenityInfo(ctx context.Context, hc interp.HandlerContext, args []string) error
- func ZenityQuestion(ctx context.Context, hc interp.HandlerContext, args []string) error
- func ZenityWarning(ctx context.Context, hc interp.HandlerContext, args []string) error
- type AferoBlob
- type AferoBlobT
- type AferoFile
- func (me AferoFile) Credentials() Credentials
- func (me AferoFile) Dir() string
- func (me AferoFile) Download() (Content, error)
- func (me AferoFile) DownloadP() Content
- func (me AferoFile) Fs() afero.Fs
- func (me AferoFile) Name() string
- func (me AferoFile) Protocol() string
- func (me AferoFile) Timeout() time.Duration
- func (me AferoFile) URL() *url.URL
- func (me AferoFile) Url() string
- type AferoFileT
- type CommandOutput
- func ParseCommandOutput(outputText string) (CommandOutput, error)
- func ParseCommandOutputP(outputText string) CommandOutput
- func RunCommandNoInput(vars map[string]string, dir string, cmd string, args ...string) (CommandOutput, error)
- func RunCommandNoInputP(vars map[string]string, dir string, cmd string, args ...string) CommandOutput
- func RunGoshCommand(vars map[string]string, dir string, cmd string, passwordInput FnInput) (CommandOutput, error)
- func RunGoshCommandP(vars map[string]string, dir string, cmd string, passwordInput FnInput) CommandOutput
- func RunShellCommand(vars map[string]string, dir string, sh string, cmd string, ...) (CommandOutput, error)
- func RunShellCommandP(vars map[string]string, dir string, sh string, cmd string, ...) CommandOutput
- func RunSudoCommand(vars map[string]string, dir string, cmd string, passwordInput FnInput) (CommandOutput, error)
- func RunUserCommand(vars map[string]string, dir string, cmd string) (CommandOutput, error)
- func RunUserCommandP(vars map[string]string, dir string, cmd string) CommandOutput
- type CommandOutputKind
- type CommandOutputT
- type ConfigConfig
- type ConfigMetadata
- func DecodeWithMap[T any](input map[string]any, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata, error)
- func DecodeWithMapP[T any](input map[string]any, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata)
- func DecodeWithYaml[T any](yamlText string, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata, error)
- func DecodeWithYamlP[T any](yamlText string, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata)
- type Content
- type ContentT
- type Credentials
- type CredentialsT
- type ErrorGroup
- type ErrorGroupT
- type EventLogger
- func (me EventLogger) LogDebug(enm event.LogEnum, hub string, topic string, lsner string)
- func (me EventLogger) LogError(enm event.LogEnum, hub string, topic string, lsner string, err any)
- func (me EventLogger) LogEventDebug(enm event.LogEnum, lsner string, evnt event.Event)
- func (me EventLogger) LogEventError(enm event.LogEnum, lsner string, evnt event.Event, err any)
- func (me EventLogger) LogEventInfo(enm event.LogEnum, lsner string, evnt event.Event)
- func (me EventLogger) LogInfo(enm event.LogEnum, hub string, topic string, lsner string)
- func (me EventLogger) Target() Logger
- type EventLoggerT
- type File
- type FnInput
- type KeyValue
- type LogContext
- type LogEntry
- type Logger
- type LoggerConfig
- type LoggerConfigT
- type LoggerT
- type OrderedMap
- func (me *OrderedMap[K]) Delete(key string)
- func (me *OrderedMap[K]) Entries() []*KeyValue[K]
- func (me *OrderedMap[K]) Find(key string) (K, bool)
- func (me *OrderedMap[K]) Get(key string) K
- func (me *OrderedMap[K]) Has(key string) bool
- func (me *OrderedMap[K]) Keys() *hashset.Set
- func (me *OrderedMap[K]) Len() int
- func (me *OrderedMap[K]) MarshalJSON() ([]byte, error)
- func (me *OrderedMap[K]) Put(key string, value K)
- func (me *OrderedMap[K]) PutAll(nameResolver func(v K) string, values []K)
- func (me *OrderedMap[K]) PutIfAbsent(key string, value K) bool
- func (me *OrderedMap[K]) SortByKey(revert bool)
- func (me *OrderedMap[K]) ToMap() map[string]K
- func (me *OrderedMap[K]) UnmarshalJSON(bytes []byte) error
- func (me *OrderedMap[K]) Values() []K
- type RemoteFile
- func (me RemoteFile) Credentials() Credentials
- func (me RemoteFile) Dir() string
- func (me RemoteFile) Download() (Content, error)
- func (me RemoteFile) DownloadP() Content
- func (me RemoteFile) Name() string
- func (me RemoteFile) Protocol() string
- func (me RemoteFile) Timeout() time.Duration
- func (me RemoteFile) URL() *url.URL
- func (me RemoteFile) Url() string
- type RemoteFileT
- type ToMap
Constants ¶
Variables ¶
var AppFs = afero.NewOsFs()
var TraceId atomic.Int64
Functions ¶
func AnyArrayToStringArray ¶ added in v2.4.3
func BoolArrayP ¶ added in v2.4.4
func BroadcastInterfacesP ¶
func CreateLockFile ¶
CreateLockFile tries to create a file with given name and acquire an exclusive lock on it. If the file already exists AND is still locked, it will fail.
func DeepCopyMap ¶
func DefaultEtcHosts ¶
func DefaultEtcHostsP ¶
func DefaultEtcHostsP() string
func DefaultOutput ¶
func DownloadBytes ¶
func DownloadBytesP ¶
func DownloadText ¶
func DownloadTextP ¶
func EnsureDirExistsP ¶
func EnsureFileExistsP ¶
func EnvironListP ¶
func ExecEnv ¶
Exec loads env vars from the specified filenames (empty map falls back to default) then executes the cmd specified.
Simply hooks up os.Stdin/err/out to the command and calls Run()
If you want more fine grained control over your command it's recommended that you use `Load()` or `Read()` and the `os/exec` package yourself.
func ExecZenity ¶
func Executable ¶
func ExecutableP ¶
func ExecutableP() string
func ExpandHomePathP ¶
func ExtractTitle ¶
func FallbackFilePath ¶
func Float ¶ added in v2.4.4
Cast the value to float64. If parsing error occurred, returns the error.
func FloatArrayP ¶ added in v2.4.4
func GoshExecHandler ¶
func GoshExecHandler(killTimeout time.Duration) interp.ExecHandlerFunc
func HasFallbackFile ¶
func InputSudoPassword ¶
func InstrumentSudoCommand ¶
func IsAsciiSpace ¶ added in v2.4.3
func IsDiscardLogger ¶
func IsEmptyReflectValue ¶
Copied From http://golang.org/src/encoding/json/encode.go Lines 280 - 296
func IsEmptyValue ¶
func IsFileProtocol ¶
func IsPrimitiveReflectValue ¶
func IsPrimitiveValue ¶
func IsSudoCommand ¶
func IsTerminal ¶
func IsTerminal() bool
func JoinedLines ¶
func JoinedLinesAsBytes ¶
func ListSuffixedFiles ¶
func ListSuffixedFilesP ¶
func LoadEnv ¶
Load will read your env file(s) and load them into ENV for this process.
Call this function as close as possible to the start of your program (ideally in main)
If you call Load without any args it will default to loading .env in the current path ¶
You can otherwise tell it which files to load (there can be more than one) like
godotenv.Load("fileone", "filetwo")
It's important to note that it WILL NOT OVERRIDE an env variable that already exists - consider the .env file to set dev vars or sensible defaults
func LoadEnvScript ¶
func LoadEnvScripts ¶
func Map2StructP ¶
func MapArray ¶ added in v2.4.0
MapArray casts the input any value to []map[string]any if the input value type matches, otherwise, return error.
func MapFromJsonFile ¶
func MapFromJsonFileP ¶
func MapFromYamlFile ¶
func MapFromYamlFileP ¶
func MarshalEnv ¶
Marshal outputs the given environment as a dotenv-formatted environment file. Each line is in the format: KEY="VALUE" where VALUE is backslash-escaped.
func OptionalBool ¶ added in v2.4.0
func OptionalBool(hint string, key string, m map[string]any, devault bool) (result bool, has bool, err error)
OptionalBool returns the bool value of the key in the map. If parsing error occrred, returns the error. If the key is not found, return the default value.
func OptionalBoolP ¶ added in v2.4.0
OptionalBoolP returns the bool value of the key in the map. If parsing error occurred, raise a panic. If the key is not found, return the default value.
func OptionalFloat ¶ added in v2.4.4
func OptionalFloat(hint string, key string, m map[string]any, devault float64) (result float64, has bool, err error)
OptionalFloat returns the float64 value of the key in the map. If parsing error occrred, returns the error. If the key is not found, return the default value.
func OptionalFloatP ¶ added in v2.4.4
func OptionalFloatP(hint string, key string, m map[string]any, devault float64) (result float64, has bool)
OptionalFloatP returns the float64 value of the key in the map. If parsing error occurred, raise a panic. If the key is not found, return the default value.
func OptionalInt ¶ added in v2.4.2
func OptionalInt(hint string, key string, m map[string]any, devault int) (result int, has bool, err error)
OptionalInt returns the int value of the key in the map. If parsing error occrred, returns the error. If the key is not found, return the default value.
func OptionalIntP ¶ added in v2.4.2
OptionalIntP returns the int value of the key in the map. If parsing error occurred, raise a panic. If the key is not found, return the default value.
func OptionalMap ¶ added in v2.4.0
func OptionalMapArray ¶ added in v2.4.0
func OptionalMapArrayP ¶ added in v2.4.0
func OptionalMapP ¶ added in v2.4.0
func OptionalString ¶ added in v2.4.0
func OptionalStringArrayValue ¶ added in v2.4.0
func OptionalStringArrayValueP ¶ added in v2.4.0
func OptionalStringP ¶ added in v2.4.0
func OverloadEnv ¶
Overload will read your env file(s) and load them into ENV for this process.
Call this function as close as possible to the start of your program (ideally in main)
If you call Overload without any args it will default to loading .env in the current path ¶
You can otherwise tell it which files to load (there can be more than one) like
godotenv.Overload("fileone", "filetwo")
It's important to note this WILL OVERRIDE an env variable that already exists - consider the .env file to forcefilly set all vars.
func ReadEnv ¶
Read all env (with same file loading semantics as Load) but return values as a map rather than automatically writing values into env
func ReadFallbackFile ¶
func ReadLockFile ¶ added in v2.4.8
If filename is a lock file, returns the PID of the process locking it
func RemoveDirP ¶
func RemoveFileP ¶
func RenderAsTemplateArray ¶
func RenderAsTemplateArrayP ¶
func RenderWithTemplate ¶
func RenderWithTemplateP ¶
func RequiredBool ¶ added in v2.4.0
RequiredBool returns the bool value of the key in the map. If either parsing error or the key is not found, an error is returned.
func RequiredBoolP ¶ added in v2.4.0
RequiredBoolP returns the bool value of the key in the map. If either parsing error or the key is not found, raise a panic.
func RequiredFloat ¶ added in v2.4.4
RequiredFloat returns the float64 value of the key in the map. If either parsing error or the key is not found, an error is returned.
func RequiredFloatP ¶ added in v2.4.4
RequiredFloatP returns the float64 value of the key in the map. If either parsing error or the key is not found, raise a panic.
func RequiredInt ¶ added in v2.4.2
RequiredInt returns the int value of the key in the map. If either parsing error or the key is not found, an error is returned.
func RequiredIntP ¶ added in v2.4.2
RequiredIntP returns the int value of the key in the map. If either parsing error or the key is not found, raise a panic.
func RequiredMap ¶ added in v2.4.0
func RequiredMapArray ¶ added in v2.4.0
func RequiredMapArrayP ¶ added in v2.4.0
func RequiredMapP ¶ added in v2.4.0
func RequiredString ¶ added in v2.4.0
func RequiredStringP ¶ added in v2.4.0
func ResolveBroadcastIp ¶
func ResolveBroadcastIpP ¶
func RunCommandWithInput ¶
func Set2Strings ¶
func ShortDescription ¶
func Slice2Set ¶
func Slice2Set[T comparable](arr ...T) *hashset.Set
func SliceEquals ¶
func SliceEquals[T comparable](a []T, b []T) bool
func StringArrayP ¶ added in v2.4.0
func StringArrayToAnyArray ¶ added in v2.4.3
func StringArrayValue ¶ added in v2.4.0
func StringArrayValueP ¶ added in v2.4.0
func StructToMap ¶
func SubstVarsP ¶
func Text2Lines ¶
func TextLine2Array ¶
func UnmarshalEnv ¶
Unmarshal reads an env file from a string, returning a map of keys and values.
func UserHomeDir ¶
func UserHomeDirP ¶
func UserHomeDirP() string
func WorkingDirectory ¶
func WorkingDirectoryP ¶
func WorkingDirectoryP() string
func WriteFallbackFile ¶
func WriteFileIfNotFound ¶
WriteIfNotFound ...
func WriteFileIfNotFoundP ¶
func WriteFileLinesP ¶
WriteLines ...
func WriteFileText ¶
WriteText ...
func WriteFileTextIfNotFound ¶
func WriteFileTextIfNotFoundP ¶
WriteTextIfNotFound ...
func ZenityError ¶
func ZenityInfo ¶
func ZenityQuestion ¶
func ZenityWarning ¶
Types ¶
type AferoBlob ¶
type AferoBlob = *AferoBlobT
type AferoBlobT ¶
type AferoBlobT struct {
// contains filtered or unexported fields
}
type AferoFile ¶
type AferoFile = *AferoFileT
func NewAferoFile ¶
func NewAferoFileP ¶
func (AferoFile) Credentials ¶
func (me AferoFile) Credentials() Credentials
type AferoFileT ¶
type AferoFileT struct {
// contains filtered or unexported fields
}
type CommandOutput ¶
type CommandOutput = *CommandOutputT
func ParseCommandOutput ¶
func ParseCommandOutput(outputText string) (CommandOutput, error)
func ParseCommandOutputP ¶
func ParseCommandOutputP(outputText string) CommandOutput
func RunCommandNoInput ¶
func RunCommandNoInputP ¶
func RunGoshCommand ¶
func RunGoshCommandP ¶
func RunShellCommand ¶
func RunShellCommandP ¶
func RunSudoCommand ¶
func RunUserCommand ¶
func RunUserCommandP ¶
func RunUserCommandP(vars map[string]string, dir string, cmd string) CommandOutput
type CommandOutputKind ¶
type CommandOutputKind byte
const ( COMMAND_OUTPUT_KIND_TEXT CommandOutputKind COMMAND_OUTPUT_KIND_VARS COMMAND_OUTPUT_KIND_JSON )
type CommandOutputT ¶
type CommandOutputT struct { Kind CommandOutputKind Vars map[string]string Text string Json any }
type ConfigConfig ¶
type ConfigConfig struct { // If ErrorUnused is true, then it is an error for there to exist // keys in the original map that were unused in the decoding process // (extra keys). ErrorUnused bool // If ErrorUnset is true, then it is an error for there to exist // fields in the result that were not set in the decoding process // (extra fields). This only applies to decoding to a struct. This // will affect all nested structs as well. ErrorUnset bool // ZeroFields, if set to true, will zero fields before writing them. // For example, a map will be emptied before decoded values are put in // it. If this is false, a map will be merged. ZeroFields bool // If WeaklyTypedInput is true, the decoder will make the following // "weak" conversions: // // - bools to string (true = "1", false = "0") // - numbers to string (base 10) // - bools to int/uint (true = 1, false = 0) // - strings to int/uint (base implied by prefix) // - int to bool (true if value != 0) // - string to bool (accepts: 1, t, T, TRUE, true, True, 0, f, F, // FALSE, false, False. Anything else is an error) // - empty array = empty map and vice versa // - negative numbers to overflowed uint values (base 10) // - slice of maps to a merged map // - single values are converted to slices if required. Each // element is weakly decoded. For example: "4" can become []int{4} // if the target type is an int slice. // WeaklyTypedInput bool // Squash will squash embedded structs. A squash tag may also be // added to an individual struct field using a tag. For example: // // type Parent struct { // Child `mapstructure:",squash"` // } Squash bool // IgnoreUntaggedFields ignores all struct fields without explicit // TagName, comparable to `mapstructure:"-"` as default behaviour. IgnoreUntaggedFields bool Metadata ConfigMetadata DoValidate bool }
Derived from mapstructure.DecodeConfig
func DynamicConfigConfig ¶
func DynamicConfigConfig() *ConfigConfig
func StrictConfigConfig ¶
func StrictConfigConfig() *ConfigConfig
func (*ConfigConfig) ToMapstruct ¶
func (me *ConfigConfig) ToMapstruct() *mapstructure.DecoderConfig
type ConfigMetadata ¶
type ConfigMetadata = mapstructure.Metadata
func DecodeWithMap ¶
func DecodeWithMap[T any](input map[string]any, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata, error)
func DecodeWithMapP ¶
func DecodeWithMapP[T any](input map[string]any, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata)
func DecodeWithYaml ¶
func DecodeWithYaml[T any](yamlText string, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata, error)
func DecodeWithYamlP ¶
func DecodeWithYamlP[T any](yamlText string, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata)
type ContentT ¶
type ContentT = models.RemoteFileContent
type Credentials ¶
type Credentials = *CredentialsT
type CredentialsT ¶
type CredentialsT = models.Credentials
type ErrorGroup ¶
type ErrorGroup = *ErrorGroupT
func NewErrorGroup ¶
func NewErrorGroup(dumpStack bool) ErrorGroup
func (ErrorGroup) Add ¶
func (me ErrorGroup) Add(err error)
func (ErrorGroup) AddAll ¶
func (me ErrorGroup) AddAll(that ErrorGroup)
func (ErrorGroup) AmountOfErrors ¶
func (me ErrorGroup) AmountOfErrors() int
func (ErrorGroup) Error ¶
func (me ErrorGroup) Error() string
func (ErrorGroup) HasError ¶
func (me ErrorGroup) HasError() bool
func (ErrorGroup) MayError ¶
func (me ErrorGroup) MayError() error
type ErrorGroupT ¶
type ErrorGroupT struct {
// contains filtered or unexported fields
}
type EventLogger ¶
type EventLogger = *EventLoggerT
func NewEventLogger ¶
func NewEventLogger(target Logger) EventLogger
func (EventLogger) LogDebug ¶
func (me EventLogger) LogDebug(enm event.LogEnum, hub string, topic string, lsner string)
func (EventLogger) LogError ¶
func (me EventLogger) LogError(enm event.LogEnum, hub string, topic string, lsner string, err any)
func (EventLogger) LogEventDebug ¶
func (me EventLogger) LogEventDebug(enm event.LogEnum, lsner string, evnt event.Event)
func (EventLogger) LogEventError ¶
func (me EventLogger) LogEventError(enm event.LogEnum, lsner string, evnt event.Event, err any)
func (EventLogger) LogEventInfo ¶
func (me EventLogger) LogEventInfo(enm event.LogEnum, lsner string, evnt event.Event)
func (EventLogger) LogInfo ¶
func (me EventLogger) LogInfo(enm event.LogEnum, hub string, topic string, lsner string)
func (EventLogger) Target ¶
func (me EventLogger) Target() Logger
type EventLoggerT ¶
type EventLoggerT struct {
// contains filtered or unexported fields
}
type File ¶
type File interface { Name() string Dir() string Url() string Protocol() string URL() *url.URL Credentials() Credentials Timeout() time.Duration DownloadP() Content Download() (Content, error) }
type LogContext ¶
type LogContext = LogEntry
func NewLogContext ¶
func NewLogContext(generateNewTraceId bool) LogContext
type Logger ¶
type Logger = *LoggerT
func NewDiscardLogger ¶
func NewDiscardLogger() Logger
func NewLoggerP ¶
func NewLoggerP(console io.Writer, config LoggerConfig, fileName string) Logger
func (Logger) NewSubLogger ¶
func (me Logger) NewSubLogger(lctx LogContext) Logger
type LoggerConfig ¶
type LoggerConfig = *LoggerConfigT
type LoggerConfigT ¶
type LoggerConfigT struct { MaxSize int `json:"max_size" yaml:"maxsize"` MaxAge int `json:"max_age" yaml:"maxage"` MaxBackups int `json:"max_backups" yaml:"maxbackups"` LocalTime bool `json:"local_time" yaml:"localtime"` Compress bool `json:"compress" yaml:"compress"` }
see lumberjack.Logger
type OrderedMap ¶
type OrderedMap[K any] struct { // contains filtered or unexported fields }
func NewOrderedMap ¶
func NewOrderedMap[K any](nilValue K) *OrderedMap[K]
func (*OrderedMap[K]) Delete ¶
func (me *OrderedMap[K]) Delete(key string)
func (*OrderedMap[K]) Entries ¶
func (me *OrderedMap[K]) Entries() []*KeyValue[K]
func (*OrderedMap[K]) Find ¶
func (me *OrderedMap[K]) Find(key string) (K, bool)
func (*OrderedMap[K]) Get ¶
func (me *OrderedMap[K]) Get(key string) K
func (*OrderedMap[K]) Has ¶
func (me *OrderedMap[K]) Has(key string) bool
func (*OrderedMap[K]) Keys ¶
func (me *OrderedMap[K]) Keys() *hashset.Set
func (*OrderedMap[K]) Len ¶
func (me *OrderedMap[K]) Len() int
func (*OrderedMap[K]) MarshalJSON ¶
func (me *OrderedMap[K]) MarshalJSON() ([]byte, error)
func (*OrderedMap[K]) Put ¶
func (me *OrderedMap[K]) Put(key string, value K)
func (*OrderedMap[K]) PutAll ¶
func (me *OrderedMap[K]) PutAll(nameResolver func(v K) string, values []K)
func (*OrderedMap[K]) PutIfAbsent ¶
func (me *OrderedMap[K]) PutIfAbsent(key string, value K) bool
func (*OrderedMap[K]) SortByKey ¶
func (me *OrderedMap[K]) SortByKey(revert bool)
func (*OrderedMap[K]) ToMap ¶ added in v2.4.1
func (me *OrderedMap[K]) ToMap() map[string]K
func (*OrderedMap[K]) UnmarshalJSON ¶
func (me *OrderedMap[K]) UnmarshalJSON(bytes []byte) error
func (*OrderedMap[K]) Values ¶
func (me *OrderedMap[K]) Values() []K
type RemoteFile ¶
type RemoteFile = *RemoteFileT
func NewRemoteFile ¶
func NewRemoteFile(url string, credentials Credentials, timeout time.Duration) (RemoteFile, error)
func NewRemoteFileP ¶
func NewRemoteFileP(url string, credentials Credentials, timeout time.Duration) RemoteFile
func (RemoteFile) Credentials ¶
func (me RemoteFile) Credentials() Credentials
func (RemoteFile) Download ¶
func (me RemoteFile) Download() (Content, error)
func (RemoteFile) DownloadP ¶
func (me RemoteFile) DownloadP() Content
func (RemoteFile) Name ¶
func (me RemoteFile) Name() string
func (RemoteFile) Protocol ¶
func (me RemoteFile) Protocol() string
remote protocol. May be used to explicitly tell what protocol to use (i.e. "http", "ftp", "etc").
func (RemoteFile) Timeout ¶
func (me RemoteFile) Timeout() time.Duration
func (RemoteFile) URL ¶
func (me RemoteFile) URL() *url.URL
type RemoteFileT ¶
type RemoteFileT struct {
// contains filtered or unexported fields
}
Source Files ¶
- afero.go
- afero_file.go
- afero_linux.go
- bool.go
- collection.go
- command.go
- command_linux.go
- config.go
- devnull.go
- error_group.go
- file.go
- file_fallback.go
- float.go
- godotenv.go
- gosh.go
- gosh_zenity.go
- int.go
- io.go
- lock_file.go
- lock_file_posix.go
- logger.go
- map.go
- mapper.go
- names.go
- net.go
- ordered_map.go
- os.go
- reflect.go
- remote_file.go
- string.go
- struct.go
- text.go