comm

package module
v2.4.8 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 45 Imported by: 0

README

go_comm

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

View Source
const (
	HTTP  = services.HTTP + "://"
	HTTPS = services.HTTPS + "://"
	FTP   = services.FTP + "://"
	FTPS  = services.FTPS + "://"
	SFTP  = services.SFTP + "://"
	S3    = services.S3 + "://"
	FILE  = "file://"
)

Variables

View Source
var AppFs = afero.NewOsFs()
View Source
var TraceId atomic.Int64

Functions

func AbsPath

func AbsPath(cwd string, _path string) string

func AnyArrayToStringArray added in v2.4.3

func AnyArrayToStringArray(anyArray []any) []string

func Bool added in v2.4.0

func Bool(hint string, v any) (bool, error)

Cast the value to bool. If parsing error occurred, returns the error.

func BoolArray added in v2.4.4

func BoolArray(hint string, v any) ([]bool, error)

func BoolArrayP added in v2.4.4

func BoolArrayP(hint string, v any) []bool

func BoolMap added in v2.4.6

func BoolMap(hint string, v any) (map[string]bool, error)

func BoolMapP added in v2.4.6

func BoolMapP(hint string, v any) map[string]bool

func BoolP added in v2.4.0

func BoolP(hint string, v any) bool

Cast the value to bool. If parsing error occurred, raise a panic.

func BroadcastInterfaces

func BroadcastInterfaces(dump bool) ([]net.Interface, error)

func BroadcastInterfacesP

func BroadcastInterfacesP(dump bool) []net.Interface

func BroadcastIpWithInterface

func BroadcastIpWithInterface(intf net.Interface) (net.IP, error)

func BroadcastIpWithInterfaceP

func BroadcastIpWithInterfaceP(intf net.Interface) net.IP

func CopyFile

func CopyFile(fs afero.Fs, path string, newPath string) (int64, error)

func CopyFileP

func CopyFileP(fs afero.Fs, path string, newPath string) int64

func CreateLockFile

func CreateLockFile(fs afero.Fs, filename string, data any) (afero.File, error)

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 DeepCopyMap[T any](that map[string]T) map[string]T

func DefaultEtcHosts

func DefaultEtcHosts() (string, error)

func DefaultEtcHostsP

func DefaultEtcHostsP() string

func DefaultOutput

func DefaultOutput() io.Writer

func DirExists

func DirExists(fs afero.Fs, path string) (bool, error)

DirExists ...

func DirExistsP

func DirExistsP(fs afero.Fs, path string) bool

func DowncastMap

func DowncastMap[V any](m map[string]V) map[string]any

func DownloadBytes

func DownloadBytes(logger Logger, fallbackDir string, fs afero.Fs, url string, credentials Credentials, timeout time.Duration) (result []byte, err error)

func DownloadBytesP

func DownloadBytesP(logger Logger, fallbackDir string, fs afero.Fs, url string, credentials Credentials, timeout time.Duration) []byte

func DownloadText

func DownloadText(logger Logger, fallbackDir string, fs afero.Fs, url string, credentials Credentials, timeout time.Duration) (string, error)

func DownloadTextP

func DownloadTextP(logger Logger, fallbackDir string, fs afero.Fs, url string, credentials Credentials, timeout time.Duration) string

func EnsureDirExists

func EnsureDirExists(fs afero.Fs, path string) error

func EnsureDirExistsP

func EnsureDirExistsP(fs afero.Fs, path string)

func EnsureFileExists

func EnsureFileExists(fs afero.Fs, path string) error

func EnsureFileExistsP

func EnsureFileExistsP(fs afero.Fs, path string)

func EnvSubst

func EnvSubst(input string, env map[string]string) (string, error)

func EnvSubstP

func EnvSubstP(input string, env map[string]string) string

func EnvSubstSlice

func EnvSubstSlice(inputs []string, env map[string]string) ([]string, error)

func EnvSubstSliceP

func EnvSubstSliceP(inputs []string, env map[string]string) []string

func EnvironList

func EnvironList(overrides map[string]string) ([]string, error)

func EnvironListP

func EnvironListP(overrides map[string]string) []string

func EnvironMap

func EnvironMap(overrides map[string]string) (map[string]string, error)

func EnvironMapP

func EnvironMapP(overrides map[string]string) map[string]string

func ExecEnv

func ExecEnv(fs afero.Fs, filenames []string, cmd string, cmdArgs []string) error

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 ExecZenity(ctx context.Context, hc interp.HandlerContext, args []string) error

func Executable

func Executable() (string, error)

func ExecutableP

func ExecutableP() string

func ExpandHomePath

func ExpandHomePath(path string) (string, error)

ExpandHomePath ...

func ExpandHomePathP

func ExpandHomePathP(path string) string

func ExtractTitle

func ExtractTitle(filePath string) string

func FallbackFilePath

func FallbackFilePath(fallbackDir string, url string) string

func FileExists

func FileExists(fs afero.Fs, path string) (bool, error)

FileExists ...

func FileExistsP

func FileExistsP(fs afero.Fs, path string) bool

func Float added in v2.4.4

func Float(hint string, v any) (float64, error)

Cast the value to float64. If parsing error occurred, returns the error.

func FloatArray added in v2.4.4

func FloatArray(hint string, v any) ([]float64, error)

func FloatArrayP added in v2.4.4

func FloatArrayP(hint string, v any) []float64

func FloatMap added in v2.4.6

func FloatMap(hint string, v any) (map[string]float64, error)

func FloatMapP added in v2.4.6

func FloatMapP(hint string, v any) map[string]float64

func FloatP added in v2.4.4

func FloatP(hint string, v any) float64

Cast the value to float64. If parsing error occurred, raise a panic.

func FromJson

func FromJson(jsonText string, envsubt bool, result any) (err error)

func FromJsonFile

func FromJsonFile(fs afero.Fs, path string, envsubt bool, result any) error

func FromJsonFileP

func FromJsonFileP(fs afero.Fs, path string, envsubt bool, result any)

func FromJsonP

func FromJsonP(jsonText string, envsubt bool, result any)

func FromYaml

func FromYaml(yamlText string, envsubt bool, result any) (err error)

func FromYamlFile

func FromYamlFile(fs afero.Fs, path string, envsubt bool, result any) error

func FromYamlFileP

func FromYamlFileP(fs afero.Fs, path string, envsubt bool, result any)

func FromYamlP

func FromYamlP(yamlText string, envsubt bool, result any)

func GetMapValue

func GetMapValue[T any](m map[string]any, key string, devault func() T) T

func GoshExecHandler

func GoshExecHandler(killTimeout time.Duration) interp.ExecHandlerFunc

func HasFallbackFile

func HasFallbackFile(fallbackDir string, fs afero.Fs, url string) (bool, error)

func Hostname

func Hostname() (string, error)

func HostnameP

func HostnameP() string

func InputSudoPassword

func InputSudoPassword(passwordInput FnInput) string

func InstrumentSudoCommand

func InstrumentSudoCommand(cmd string) string

func Int added in v2.4.2

func Int(hint string, v any) (int, error)

Cast the value to int. If parsing error occurred, returns the error.

func IntArray added in v2.4.4

func IntArray(hint string, v any) ([]int, error)

func IntArrayP added in v2.4.4

func IntArrayP(hint string, v any) []int

func IntMap added in v2.4.6

func IntMap(hint string, v any) (map[string]int, error)

func IntMapP added in v2.4.6

func IntMapP(hint string, v any) map[string]int

func IntP added in v2.4.2

func IntP(hint string, v any) int

Cast the value to int. If parsing error occurred, raise a panic.

func IsAsciiSpace added in v2.4.3

func IsAsciiSpace(s uint8) bool

func IsDarwin

func IsDarwin() bool

func IsDiscardLogger

func IsDiscardLogger(logger Logger) bool

func IsEmptyReflectValue

func IsEmptyReflectValue(v reflect.Value) bool

Copied From http://golang.org/src/encoding/json/encode.go Lines 280 - 296

func IsEmptyValue

func IsEmptyValue(v any) bool

func IsFileProtocol

func IsFileProtocol(url string) bool

func IsLinux

func IsLinux() bool

func IsPrimitiveReflectValue

func IsPrimitiveReflectValue(v reflect.Value) bool

func IsPrimitiveValue

func IsPrimitiveValue(v any) bool

func IsRemote

func IsRemote(url string) bool

func IsSudoCommand

func IsSudoCommand(cmd string) bool

func IsTerminal

func IsTerminal() bool

func IsWindows

func IsWindows() bool

func JoinedLines

func JoinedLines(lines ...string) string

func JoinedLinesAsBytes

func JoinedLinesAsBytes(lines ...string) []byte

func ListSuffixedFiles

func ListSuffixedFiles(fs afero.Fs, targetDir string, suffix string, skipEmptyFile bool) (map[string]string, error)

func ListSuffixedFilesP

func ListSuffixedFilesP(fs afero.Fs, targetDir string, suffix string, skipEmptyFile bool) map[string]string

func LoadEnv

func LoadEnv(fs afero.Fs, filenames ...string) (err error)

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 LoadEnvScript(fs afero.Fs, vars map[string]string, filename string) (map[string]string, error)

func LoadEnvScripts

func LoadEnvScripts(fs afero.Fs, vars map[string]string, filenames ...string) (map[string]string, error)

func LogMap added in v2.3.1

func LogMap(logger *plog.Entry, key string, m map[string]any) *plog.Entry

func LogMapper added in v2.3.1

func LogMapper(logger *plog.Entry, key string, mapper ToMap) *plog.Entry

func Map added in v2.4.0

func Map(hint string, v any) (map[string]any, error)

func Map2Struct

func Map2Struct(src map[string]any, dest any) error

func Map2StructP

func Map2StructP(src map[string]any, dest any)

func MapArray added in v2.4.0

func MapArray(hint string, v any) ([]map[string]any, error)

MapArray casts the input any value to []map[string]any if the input value type matches, otherwise, return error.

func MapArrayP added in v2.4.0

func MapArrayP(hint string, v any) []map[string]any

func MapFromJson

func MapFromJson(yamlText string, envsubt bool) (map[string]any, error)

func MapFromJsonFile

func MapFromJsonFile(fs afero.Fs, path string, envsubt bool) (map[string]any, error)

func MapFromJsonFileP

func MapFromJsonFileP(fs afero.Fs, path string, envsubt bool) map[string]any

func MapFromJsonP

func MapFromJsonP(yamlText string, envsubt bool) map[string]any

func MapFromYaml

func MapFromYaml(yamlText string, envsubt bool) (map[string]any, error)

func MapFromYamlFile

func MapFromYamlFile(fs afero.Fs, path string, envsubt bool) (map[string]any, error)

func MapFromYamlFileP

func MapFromYamlFileP(fs afero.Fs, path string, envsubt bool) map[string]any

func MapFromYamlP

func MapFromYamlP(yamlText string, envsubt bool) map[string]any

func MapP added in v2.4.0

func MapP(hint string, v any) map[string]any

func MarshalEnv

func MarshalEnv(envMap map[string]string) (string, error)

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 MergeMap

func MergeMap[T any](bases ...map[string]T) map[string]T

func Mkdir

func Mkdir(fs afero.Fs, path string) error

Mkdir ...

func MkdirP

func MkdirP(fs afero.Fs, path string)

func NameOfKey added in v2.4.0

func NameOfKey(key string) string

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

func OptionalBoolP(hint string, key string, m map[string]any, devault bool) (result bool, has bool)

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

func OptionalIntP(hint string, key string, m map[string]any, devault int) (result int, has bool)

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 OptionalMap(hint string, key string, m map[string]any, defaultresult map[string]any) (result map[string]any, has bool, err error)

func OptionalMapArray added in v2.4.0

func OptionalMapArray(hint string, key string, m map[string]any, defaultresult []map[string]any) (result []map[string]any, has bool, err error)

func OptionalMapArrayP added in v2.4.0

func OptionalMapArrayP(hint string, key string, m map[string]any, defaultresult []map[string]any) (result []map[string]any, has bool)

func OptionalMapP added in v2.4.0

func OptionalMapP(hint string, key string, m map[string]any, defaultresult map[string]any) (result map[string]any, has bool)

func OptionalString added in v2.4.0

func OptionalString(hint string, key string, m map[string]any, devault string) (result string, has bool, err error)

func OptionalStringArrayValue added in v2.4.0

func OptionalStringArrayValue(hint string, key string, m map[string]any, devault []string) (result []string, has bool, err error)

func OptionalStringArrayValueP added in v2.4.0

func OptionalStringArrayValueP(hint string, key string, m map[string]any, devault []string) (result []string, has bool)

func OptionalStringP added in v2.4.0

func OptionalStringP(hint string, key string, m map[string]any, devault string) (result string, has bool)

func OverloadEnv

func OverloadEnv(fs afero.Fs, filenames ...string) (err error)

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 Pair2Vars

func Pair2Vars(pairs []string) map[string]string

func ParseEnv

func ParseEnv(r io.Reader) (envMap map[string]string, err error)

Parse reads an env file from io.Reader, returning a map of keys and values.

func ReadBytes

func ReadBytes(reader io.Reader) ([]byte, error)

ReadBytes ...

func ReadBytesP

func ReadBytesP(reader io.Reader) []byte

ReadBytesP ...

func ReadEnv

func ReadEnv(fs afero.Fs, filenames ...string) (envMap map[string]string, err error)

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 ReadFallbackFile(fallbackDir string, fs afero.Fs, url string) (string, []byte, error)

func ReadFileBytes

func ReadFileBytes(fs afero.Fs, path string) ([]byte, error)

ReadBytes ...

func ReadFileBytesP

func ReadFileBytesP(fs afero.Fs, path string) []byte

func ReadFileLines

func ReadFileLines(fs afero.Fs, path string) ([]string, error)

func ReadFileLinesP

func ReadFileLinesP(fs afero.Fs, path string) []string

func ReadFileText

func ReadFileText(fs afero.Fs, path string) (string, error)

func ReadFileTextP

func ReadFileTextP(fs afero.Fs, path string) string

func ReadLines

func ReadLines(reader io.Reader) []string

func ReadLockFile added in v2.4.8

func ReadLockFile(fs afero.Fs, filename string) (int, any, error)

If filename is a lock file, returns the PID of the process locking it

func ReadText

func ReadText(reader io.Reader) (string, error)

ReadText ...

func ReadTextP

func ReadTextP(reader io.Reader) string

ReadText ...

func RemoveDir

func RemoveDir(fs afero.Fs, path string) error

RemoveDir ...

func RemoveDirP

func RemoveDirP(fs afero.Fs, path string)

func RemoveFile

func RemoveFile(fs afero.Fs, path string) error

RemoveFile ...

func RemoveFileP

func RemoveFileP(fs afero.Fs, path string)

func Rename

func Rename(fs afero.Fs, path string, newPath string) error

func RenameP

func RenameP(fs afero.Fs, path string, newPath string)

func RenderAsTemplate

func RenderAsTemplate(tmpl string, data map[string]any) (string, error)

func RenderAsTemplateArray

func RenderAsTemplateArray(tmplArray []string, data map[string]any) ([]string, error)

func RenderAsTemplateArrayP

func RenderAsTemplateArrayP(tmplArray []string, data map[string]any) []string

func RenderAsTemplateP

func RenderAsTemplateP(tmpl string, data map[string]any) string

func RenderWithTemplate

func RenderWithTemplate(w io.Writer, name string, tmpl string, data map[string]any) error

func RenderWithTemplateP

func RenderWithTemplateP(w io.Writer, name string, tmpl string, data map[string]any)

func RequiredBool added in v2.4.0

func RequiredBool(hint string, key string, m map[string]any) (bool, error)

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

func RequiredBoolP(hint string, key string, m map[string]any) bool

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

func RequiredFloat(hint string, key string, m map[string]any) (float64, error)

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

func RequiredFloatP(hint string, key string, m map[string]any) float64

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

func RequiredInt(hint string, key string, m map[string]any) (int, error)

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

func RequiredIntP(hint string, key string, m map[string]any) int

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 RequiredMap(hint string, key string, m map[string]any) (map[string]any, error)

func RequiredMapArray added in v2.4.0

func RequiredMapArray(hint string, key string, m map[string]any) ([]map[string]any, error)

func RequiredMapArrayP added in v2.4.0

func RequiredMapArrayP(hint string, key string, m map[string]any) []map[string]any

func RequiredMapP added in v2.4.0

func RequiredMapP(hint string, key string, m map[string]any) map[string]any

func RequiredString added in v2.4.0

func RequiredString(hint string, key string, m map[string]any) (string, error)

func RequiredStringP added in v2.4.0

func RequiredStringP(hint string, key string, m map[string]any) string

func ResolveBroadcastIp

func ResolveBroadcastIp(interfaces []net.Interface, interfaceName string) (net.IP, net.IP, error)

func ResolveBroadcastIpP

func ResolveBroadcastIpP(interfaces []net.Interface, interfaceName string) (net.IP, net.IP)

func RunCommandWithInput

func RunCommandWithInput(vars map[string]string, dir string, cmd string, args ...string) func(...string) (CommandOutput, error)

func Set2Strings

func Set2Strings(set *hashset.Set) []string

func ShortDescription

func ShortDescription(url string) string

func Slice2Map

func Slice2Map[V any](arr []V, keyFunc func(v V) string) map[string]V

func Slice2Set

func Slice2Set[T comparable](arr ...T) *hashset.Set

func SliceEquals

func SliceEquals[T comparable](a []T, b []T) bool

func Stat

func Stat(fs afero.Fs, path string, ensureExists bool) (os.FileInfo, error)

Stat ...

func StatP

func StatP(fs afero.Fs, path string, ensureExists bool) os.FileInfo

func String added in v2.4.0

func String(hint string, v any) (string, error)

func StringArray added in v2.4.0

func StringArray(hint string, v any) ([]string, error)

func StringArrayP added in v2.4.0

func StringArrayP(hint string, v any) []string

func StringArrayToAnyArray added in v2.4.3

func StringArrayToAnyArray(stringArray []string) []any

func StringArrayValue added in v2.4.0

func StringArrayValue(hint string, key string, m map[string]any) ([]string, error)

func StringArrayValueP added in v2.4.0

func StringArrayValueP(hint string, key string, m map[string]any) []string

func StringMap added in v2.4.6

func StringMap(hint string, v any) (map[string]string, error)

func StringMapP added in v2.4.6

func StringMapP(hint string, v any) map[string]string

func StringP added in v2.4.0

func StringP(hint string, v any) string

func StructToMap

func StructToMap(src any) map[string]any

func SubstVars

func SubstVars(useGoTemplate bool, m map[string]any, parentVars map[string]any, keysToSkip ...string) (map[string]any, error)

func SubstVarsP

func SubstVarsP(useGoTemplate bool, m map[string]any, parentVars map[string]any, keysToSkip ...string) map[string]any

func SysEnvFileNames

func SysEnvFileNames(fs afero.Fs, shell string) []string

func TempFile

func TempFile(fs afero.Fs, pattern string) (string, error)

func TempFileP

func TempFileP(fs afero.Fs, pattern string) string

func TempTextFile

func TempTextFile(fs afero.Fs, pattern string, content string) (string, error)

func TempTextFileP

func TempTextFileP(fs afero.Fs, pattern string, content string) string

func Text2Lines

func Text2Lines(text string) []string

func Text2Vars

func Text2Vars(text string) map[string]string

func TextLine2Array

func TextLine2Array(line string) []string

func ToYaml

func ToYaml(hint string, me any) (string, error)

func ToYamlP

func ToYamlP(hint string, me any) string

func UnmarshalEnv

func UnmarshalEnv(str string) (envMap map[string]string, err error)

Unmarshal reads an env file from a string, returning a map of keys and values.

func UserHomeDir

func UserHomeDir() (string, error)

func UserHomeDirP

func UserHomeDirP() string

func Vars2Pair

func Vars2Pair(vars map[string]string) []string

func WorkDir

func WorkDir(url string, defaultDir string) string

func WorkingDirectory

func WorkingDirectory() (string, error)

func WorkingDirectoryP

func WorkingDirectoryP() string

func WriteEnv

func WriteEnv(fs afero.Fs, envMap map[string]string, filename string) error

Write serializes the given environment and writes it to a file

func WriteFallbackFile

func WriteFallbackFile(fallbackDir string, fs afero.Fs, url string, bytes []byte) (string, error)

func WriteFile

func WriteFile(fs afero.Fs, path string, content []byte) error

Write ...

func WriteFileIfNotFound

func WriteFileIfNotFound(fs afero.Fs, path string, content []byte) (bool, error)

WriteIfNotFound ...

func WriteFileIfNotFoundP

func WriteFileIfNotFoundP(fs afero.Fs, path string, content []byte) bool

func WriteFileLines

func WriteFileLines(fs afero.Fs, path string, lines ...string) error

func WriteFileLinesP

func WriteFileLinesP(fs afero.Fs, path string, lines ...string)

WriteLines ...

func WriteFileP

func WriteFileP(fs afero.Fs, path string, content []byte)

func WriteFileText

func WriteFileText(fs afero.Fs, path string, content string) error

WriteText ...

func WriteFileTextIfNotFound

func WriteFileTextIfNotFound(fs afero.Fs, path string, content string) (bool, error)

func WriteFileTextIfNotFoundP

func WriteFileTextIfNotFoundP(fs afero.Fs, path string, content string) bool

WriteTextIfNotFound ...

func WriteFileTextP

func WriteFileTextP(fs afero.Fs, path string, content string)

func ZenityError

func ZenityError(ctx context.Context, hc interp.HandlerContext, args []string) error

func ZenityInfo

func ZenityInfo(ctx context.Context, hc interp.HandlerContext, args []string) error

func ZenityQuestion

func ZenityQuestion(ctx context.Context, hc interp.HandlerContext, args []string) error

func ZenityWarning

func ZenityWarning(ctx context.Context, hc interp.HandlerContext, args []string) error

Types

type AferoBlob

type AferoBlob = *AferoBlobT

func NewAferoBlob

func NewAferoBlob(afs afero.Fs, path string) AferoBlob

func (AferoBlob) Close

func (me AferoBlob) Close() error

func (AferoBlob) Fs

func (me AferoBlob) Fs() afero.Fs

func (AferoBlob) Path

func (me AferoBlob) Path() string

func (AferoBlob) Read

func (me AferoBlob) Read(p []byte) (n int, err error)

type AferoBlobT

type AferoBlobT struct {
	// contains filtered or unexported fields
}

type AferoFile

type AferoFile = *AferoFileT

func NewAferoFile

func NewAferoFile(afs afero.Fs, apath string, credentials Credentials, timeout time.Duration) (AferoFile, error)

func NewAferoFileP

func NewAferoFileP(afs afero.Fs, apath string, credentials Credentials, timeout time.Duration) AferoFile

func (AferoFile) Credentials

func (me AferoFile) Credentials() Credentials

func (AferoFile) Dir

func (me AferoFile) Dir() string

filepath

func (AferoFile) Download

func (me AferoFile) Download() (Content, error)

func (AferoFile) DownloadP

func (me AferoFile) DownloadP() Content

func (AferoFile) Fs

func (me AferoFile) Fs() afero.Fs

func (AferoFile) Name

func (me AferoFile) Name() string

func (AferoFile) Protocol

func (me AferoFile) Protocol() string

remote protocol. May be used to explicitly tell what protocol to use (i.e. "http", "ftp", "etc").

func (AferoFile) Timeout

func (me AferoFile) Timeout() time.Duration

func (AferoFile) URL

func (me AferoFile) URL() *url.URL

func (AferoFile) Url

func (me AferoFile) Url() string

remote file/dir url

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 RunCommandNoInput(vars map[string]string, dir string, cmd string, args ...string) (CommandOutput, error)

func RunCommandNoInputP

func RunCommandNoInputP(vars map[string]string, dir string, cmd string, args ...string) CommandOutput

func RunGoshCommand

func RunGoshCommand(vars map[string]string, dir string, cmd string, passwordInput FnInput) (CommandOutput, error)

func RunGoshCommandP

func RunGoshCommandP(vars map[string]string, dir string, cmd string, passwordInput FnInput) CommandOutput

func RunShellCommand

func RunShellCommand(vars map[string]string, dir string, sh string, cmd string, passwordInput FnInput) (CommandOutput, error)

func RunShellCommandP

func RunShellCommandP(vars map[string]string, dir string, sh string, cmd string, passwordInput FnInput) CommandOutput

func RunSudoCommand

func RunSudoCommand(vars map[string]string, dir string, cmd string, passwordInput FnInput) (CommandOutput, error)

func RunUserCommand

func RunUserCommand(vars map[string]string, dir string, cmd string) (CommandOutput, error)

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 Content

type Content = *ContentT

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)
}

func NewFile

func NewFile(afs afero.Fs, url string, credentials Credentials, timeout time.Duration) (File, error)

func NewFileP

func NewFileP(afs afero.Fs, url string, credentials Credentials, timeout time.Duration) File

type FnInput

type FnInput func() string

type KeyValue

type KeyValue[K any] struct {
	Key   string
	Value K
}

type LogContext

type LogContext = LogEntry

func NewLogContext

func NewLogContext(generateNewTraceId bool) LogContext

type LogEntry

type LogEntry = *plog.Entry

type Logger

type Logger = *LoggerT

func NewDiscardLogger

func NewDiscardLogger() Logger

func NewLogger

func NewLogger(console io.Writer, config LoggerConfig, fileName string) (Logger, error)

/ verbose: log to console if true

func NewLoggerP

func NewLoggerP(console io.Writer, config LoggerConfig, fileName string) Logger

func (Logger) Close

func (me Logger) Close()

func (Logger) Error

func (me Logger) Error(err any) LogEntry

func (Logger) NewSubLogger

func (me Logger) NewSubLogger(lctx LogContext) Logger

func (Logger) Parent

func (me Logger) Parent() 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 LoggerT

type LoggerT struct {
	plog.Logger
	// contains filtered or unexported fields
}

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) Dir

func (me RemoteFile) Dir() string

filepath

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

func (RemoteFile) Url

func (me RemoteFile) Url() string

remote file/dir url

type RemoteFileT

type RemoteFileT struct {
	// contains filtered or unexported fields
}

type ToMap added in v2.3.1

type ToMap interface {
	ToMap() map[string]any
}

Directories

Path Synopsis
playground

Jump to

Keyboard shortcuts

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