comm

package module
v2.2.21 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 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 added in v2.2.16

func AbsPath(cwd string, _path string) string

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 added in v2.2.0

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

func CopyFileP added in v2.2.0

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

func CreateLockFile added in v2.2.0

func CreateLockFile(fs afero.Fs, filename string) (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 added in v2.2.8

func DeepCopyMap[T any](that map[string]T) map[string]T

func DefaultEtcHosts added in v2.2.0

func DefaultEtcHosts() (string, error)

func DefaultEtcHostsP added in v2.2.0

func DefaultEtcHostsP() string

func DefaultOutput

func DefaultOutput() io.Writer

func DirExists added in v2.2.0

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

DirExists ...

func DirExistsP added in v2.2.0

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

func DowncastMap

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

func DownloadBytes added in v2.2.0

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

func DownloadBytesP added in v2.2.0

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

func DownloadText added in v2.2.0

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

func DownloadTextP added in v2.2.0

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

func EnsureDirExists added in v2.2.0

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

func EnsureDirExistsP added in v2.2.0

func EnsureDirExistsP(fs afero.Fs, path string)

func EnsureFileExists added in v2.2.0

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

func EnsureFileExistsP added in v2.2.0

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 added in v2.2.2

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 added in v2.2.0

func ExpandHomePath(path string) (string, error)

ExpandHomePath ...

func ExpandHomePathP added in v2.2.0

func ExpandHomePathP(path string) string

func ExtractTitle added in v2.2.0

func ExtractTitle(filePath string) string

func FallbackFilePath added in v2.2.0

func FallbackFilePath(fallbackDir string, url string) string

func FileExists added in v2.2.0

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

FileExists ...

func FileExistsP added in v2.2.0

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

func FromJson added in v2.2.9

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

func FromJsonFile added in v2.2.9

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

func FromJsonFileP added in v2.2.9

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

func FromJsonP added in v2.2.9

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

func FromYaml added in v2.2.0

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

func FromYamlFile added in v2.2.0

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

func FromYamlFileP added in v2.2.0

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

func FromYamlP added in v2.2.0

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

func GetLockFilePid added in v2.2.0

func GetLockFilePid(fs afero.Fs, filename string) (pid int, err error)

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

func GetMapValue added in v2.2.13

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 added in v2.2.0

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

func Hostname

func Hostname() (string, error)

func HostnameP

func HostnameP() string

func InputSudoPassword added in v2.0.3

func InputSudoPassword(passwordInput FnInput) string

func InstrumentSudoCommand added in v2.0.3

func InstrumentSudoCommand(cmd string) string

func IsDarwin

func IsDarwin() bool

func IsDiscardLogger added in v2.2.2

func IsDiscardLogger(logger Logger) bool

func IsEmptyReflectValue added in v2.2.10

func IsEmptyReflectValue(v reflect.Value) bool

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

func IsEmptyValue added in v2.2.12

func IsEmptyValue(v any) bool

func IsFileProtocol added in v2.2.0

func IsFileProtocol(url string) bool

func IsLinux

func IsLinux() bool

func IsPrimitiveReflectValue added in v2.2.10

func IsPrimitiveReflectValue(v reflect.Value) bool

func IsPrimitiveValue added in v2.2.12

func IsPrimitiveValue(v any) bool

func IsRemote added in v2.2.0

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 added in v2.2.0

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

func ListSuffixedFilesP added in v2.2.0

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

func LoadEnv added in v2.2.2

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 added in v2.2.17

func LoadEnvScript(fs afero.Fs, vars map[string]string, filename string) (map[string]string, error)

func LoadEnvScripts added in v2.2.17

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

func Map2Struct

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

func Map2StructP

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

func MapFromJson added in v2.2.9

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

func MapFromJsonFile added in v2.2.9

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

func MapFromJsonFileP added in v2.2.9

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

func MapFromJsonP added in v2.2.9

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

func MapFromYaml added in v2.2.0

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

func MapFromYamlFile added in v2.2.0

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

func MapFromYamlFileP added in v2.2.0

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

func MapFromYamlP added in v2.2.0

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

func MarshalEnv added in v2.2.2

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 added in v2.2.1

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

func Mkdir added in v2.2.0

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

Mkdir ...

func MkdirP added in v2.2.0

func MkdirP(fs afero.Fs, path string)

func OverloadEnv added in v2.2.2

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 added in v2.2.2

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 added in v2.2.2

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 added in v2.2.0

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

func ReadFileBytes added in v2.2.0

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

ReadBytes ...

func ReadFileBytesP added in v2.2.0

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

func ReadFileLines added in v2.2.0

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

func ReadFileLinesP added in v2.2.0

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

func ReadFileText added in v2.2.0

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

func ReadFileTextP added in v2.2.0

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

func ReadLines

func ReadLines(reader io.Reader) []string

func ReadText

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

ReadText ...

func ReadTextP

func ReadTextP(reader io.Reader) string

ReadText ...

func RemoveDir added in v2.2.0

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

RemoveDir ...

func RemoveDirP added in v2.2.0

func RemoveDirP(fs afero.Fs, path string)

func RemoveFile added in v2.2.0

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

RemoveFile ...

func RemoveFileP added in v2.2.0

func RemoveFileP(fs afero.Fs, path string)

func Rename added in v2.2.0

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

func RenameP added in v2.2.0

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 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 added in v2.2.5

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

func ShortDescription added in v2.2.0

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 added in v2.2.0

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

Stat ...

func StatP added in v2.2.0

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

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 added in v2.2.17

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

func TempFile added in v2.2.0

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

func TempFileP added in v2.2.0

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

func TempTextFile added in v2.2.0

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

func TempTextFileP added in v2.2.0

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 added in v2.2.2

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 added in v2.2.0

func UserHomeDir() (string, error)

func UserHomeDirP added in v2.2.0

func UserHomeDirP() string

func Vars2Pair

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

func WorkDir added in v2.2.0

func WorkDir(url string, defaultDir string) string

func WorkingDirectory

func WorkingDirectory() (string, error)

func WorkingDirectoryP

func WorkingDirectoryP() string

func WriteEnv added in v2.2.2

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 added in v2.2.0

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

func WriteFile added in v2.2.0

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

Write ...

func WriteFileIfNotFound added in v2.2.0

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

WriteIfNotFound ...

func WriteFileIfNotFoundP added in v2.2.0

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

func WriteFileLines added in v2.2.0

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

func WriteFileLinesP added in v2.2.0

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

WriteLines ...

func WriteFileP added in v2.2.0

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

func WriteFileText added in v2.2.0

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

WriteText ...

func WriteFileTextIfNotFound added in v2.2.0

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

func WriteFileTextIfNotFoundP added in v2.2.0

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

WriteTextIfNotFound ...

func WriteFileTextP added in v2.2.0

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 added in v2.2.0

type AferoBlob = *AferoBlobT

func NewAferoBlob added in v2.2.0

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

func (AferoBlob) Close added in v2.2.0

func (me AferoBlob) Close() error

func (AferoBlob) Fs added in v2.2.0

func (me AferoBlob) Fs() afero.Fs

func (AferoBlob) Path added in v2.2.0

func (me AferoBlob) Path() string

func (AferoBlob) Read added in v2.2.0

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

type AferoBlobT added in v2.2.0

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

type AferoFile added in v2.2.0

type AferoFile = *AferoFileT

func NewAferoFile added in v2.2.0

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

func NewAferoFileP added in v2.2.0

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

func (AferoFile) Credentials added in v2.2.0

func (me AferoFile) Credentials() Credentials

func (AferoFile) Dir added in v2.2.0

func (me AferoFile) Dir() string

filepath

func (AferoFile) Download added in v2.2.0

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

func (AferoFile) DownloadP added in v2.2.0

func (me AferoFile) DownloadP() Content

func (AferoFile) Fs added in v2.2.0

func (me AferoFile) Fs() afero.Fs

func (AferoFile) Name added in v2.2.0

func (me AferoFile) Name() string

func (AferoFile) Protocol added in v2.2.0

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 added in v2.2.0

func (me AferoFile) Timeout() time.Duration

func (AferoFile) URL added in v2.2.0

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

func (AferoFile) Url added in v2.2.0

func (me AferoFile) Url() string

remote file/dir url

type AferoFileT added in v2.2.0

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 added in v2.2.1

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 added in v2.2.1

func DynamicConfigConfig() *ConfigConfig

func StrictConfigConfig added in v2.2.1

func StrictConfigConfig() *ConfigConfig

func (*ConfigConfig) ToMapstruct added in v2.2.1

func (me *ConfigConfig) ToMapstruct() *mapstructure.DecoderConfig

type ConfigMetadata added in v2.2.11

type ConfigMetadata = mapstructure.Metadata

func DecodeWithMap added in v2.2.3

func DecodeWithMap[T any](input map[string]any, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata, error)

func DecodeWithMapP added in v2.2.3

func DecodeWithMapP[T any](input map[string]any, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata)

func DecodeWithYaml added in v2.2.1

func DecodeWithYaml[T any](yamlText string, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata, error)

func DecodeWithYamlP added in v2.2.1

func DecodeWithYamlP[T any](yamlText string, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata)

type Content added in v2.2.0

type Content = *ContentT

type ContentT added in v2.2.0

type ContentT = models.RemoteFileContent

type Credentials added in v2.2.0

type Credentials = *CredentialsT

type CredentialsT added in v2.2.0

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 added in v2.1.3

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 added in v2.2.17

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 added in v2.2.0

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 added in v2.2.0

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

func NewFileP added in v2.2.0

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

type FnInput

type FnInput func() string

type KeyValue added in v2.1.0

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 added in v2.1.0

type OrderedMap[K any] struct {
	// contains filtered or unexported fields
}

func NewOrderedMap added in v2.1.0

func NewOrderedMap[K any](nilValue K) *OrderedMap[K]

func (*OrderedMap[K]) Delete added in v2.1.0

func (me *OrderedMap[K]) Delete(key string)

func (*OrderedMap[K]) Entries added in v2.1.0

func (me *OrderedMap[K]) Entries() []*KeyValue[K]

func (*OrderedMap[K]) Find added in v2.1.0

func (me *OrderedMap[K]) Find(key string) (K, bool)

func (*OrderedMap[K]) Get added in v2.1.0

func (me *OrderedMap[K]) Get(key string) K

func (*OrderedMap[K]) Has added in v2.1.0

func (me *OrderedMap[K]) Has(key string) bool

func (*OrderedMap[K]) Keys added in v2.1.0

func (me *OrderedMap[K]) Keys() *hashset.Set

func (*OrderedMap[K]) Len added in v2.1.0

func (me *OrderedMap[K]) Len() int

func (*OrderedMap[K]) MarshalJSON added in v2.1.0

func (me *OrderedMap[K]) MarshalJSON() ([]byte, error)

func (*OrderedMap[K]) Put added in v2.1.1

func (me *OrderedMap[K]) Put(key string, value K)

func (*OrderedMap[K]) PutAll added in v2.1.1

func (me *OrderedMap[K]) PutAll(nameResolver func(v K) string, values []K)

func (*OrderedMap[K]) PutIfAbsent added in v2.1.2

func (me *OrderedMap[K]) PutIfAbsent(key string, value K) bool

func (*OrderedMap[K]) SortByKey added in v2.1.5

func (me *OrderedMap[K]) SortByKey(revert bool)

func (*OrderedMap[K]) UnmarshalJSON added in v2.1.0

func (me *OrderedMap[K]) UnmarshalJSON(bytes []byte) error

func (*OrderedMap[K]) Values added in v2.1.0

func (me *OrderedMap[K]) Values() []K

type RemoteFile added in v2.2.0

type RemoteFile = *RemoteFileT

func NewRemoteFile added in v2.2.0

func NewRemoteFile(url string, credentials Credentials, timeout time.Duration) (RemoteFile, error)

func NewRemoteFileP added in v2.2.0

func NewRemoteFileP(url string, credentials Credentials, timeout time.Duration) RemoteFile

func (RemoteFile) Credentials added in v2.2.0

func (me RemoteFile) Credentials() Credentials

func (RemoteFile) Dir added in v2.2.0

func (me RemoteFile) Dir() string

filepath

func (RemoteFile) Download added in v2.2.0

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

func (RemoteFile) DownloadP added in v2.2.0

func (me RemoteFile) DownloadP() Content

func (RemoteFile) Name added in v2.2.0

func (me RemoteFile) Name() string

func (RemoteFile) Protocol added in v2.2.0

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 added in v2.2.0

func (me RemoteFile) Timeout() time.Duration

func (RemoteFile) URL added in v2.2.0

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

func (RemoteFile) Url added in v2.2.0

func (me RemoteFile) Url() string

remote file/dir url

type RemoteFileT added in v2.2.0

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

Directories

Path Synopsis
playground

Jump to

Keyboard shortcuts

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