Documentation
¶
Overview ¶
The MIT License (MIT) # Copyright (c) 2015 Shaba Abhiram Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* ignore is a library which returns a new ignorer object which can test against various paths. This is particularly useful when trying to filter files based on a .gitignore document
The rules for parsing the input file are the same as the ones listed in the Git docs here: http://git-scm.com/docs/gitignore
The summarized version of the same has been copied here:
A blank line matches no files, so it can serve as a separator for readability.
A line starting with # serves as a comment. Put a backslash ("\") in front of the first hash for patterns that begin with a hash.
Trailing spaces are ignored unless they are quoted with backslash ("\").
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "\!important!.txt".
If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in Git).
If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file).
Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".
A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning: i. A leading "**" followed by a slash means match in all directories. For example, "** /foo" matches file or directory "foo" anywhere, the same as pattern "foo". "** /foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo". ii. A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth. iii. A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/** /b" matches "a/b", "a/x/b", "a/x/y/b" and so on. iv. Other consecutive asterisks are considered invalid.
Copyright (c) 2013 John Barton
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 ¶
- Variables
- func AbsPath(_path string) (string, error)
- func AbsPathP(_path string) string
- func AbsPathWith(_path string, workDir string) (string, error)
- func AbsPathWithP(_path string, workDir string) string
- func AnyArrayToStringArray(anyArray []any) []string
- func CopyFile(fs afero.Fs, path string, newPath string) (int64, error)
- func CopyFileP(fs afero.Fs, path string, newPath string) int64
- func DeepCopyMap[T any](that map[string]T) map[string]T
- 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 DurationHookFunc(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, error)
- 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 EnsurePathExists(fs afero.Fs, path string) error
- func EnsurePathExistsP(fs afero.Fs, path string)
- func EnvDoubleQuoteEscape(line string) string
- func EnvExpandVariables(v string, m map[string]string) string
- func EnvFilenamesOrDefault(filenames []string) []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 ExecGit(fs afero.Fs, workDir string, args []string, trim bool) (string, error)
- func Executable() (string, error)
- func ExecutableP() string
- func ExpandHomePath(path string) (string, error)
- func ExpandHomePathP(path string) string
- func ExtractMarkdownCodeBlocks(input string) (string, string, error)
- func ExtractMarkdownCodeBlocksP(input string) (string, string)
- func ExtractMarkdownJsonBlocks(input string) (string, string, error)
- func ExtractMarkdownJsonBlocksP(input string) (string, string)
- func ExtractTitle(filePath string) string
- func FileExists(fs afero.Fs, path string) (bool, error)
- func FileExistsP(fs afero.Fs, path string) bool
- func FixJson(input string, isGolang bool) string
- func FixJsonExtraEscapes(input string) string
- func FixJsonImports(input string) string
- func FixJsonQuotes(input string) string
- func FixJsonUnclosedBrackets(input string) string
- func FormatDurationForConsole(d time.Duration) string
- 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 GetGitStatus(fs afero.Fs, workDir string) (string, error)
- func GetMapValue[T any](m map[string]any, key string, devault func() T) T
- func GetUnstagedFiles(fs afero.Fs, workDir string) ([]string, error)
- func GitDirectory(fs afero.Fs, filePath string) string
- func IsAsciiSpace(s uint8) bool
- func IsDarwin() bool
- func IsDir(fs afero.Fs, path string) (bool, error)
- func IsDirP(fs afero.Fs, path string) bool
- func IsFile(fs afero.Fs, path string) (bool, error)
- func IsFileP(fs afero.Fs, path string) bool
- func IsGitInited(fs afero.Fs, workDir string) bool
- func IsIgnoredEnvLine(line string) bool
- func IsLinux() 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 LoadEnvFile(fs afero.Fs, filename string) error
- func LoadEnvMap(envMap map[string]string)
- 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 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 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 ParseEnv(r io.Reader) (envMap map[string]string, err error)
- func ParseEnvLine(line string, envMap map[string]string) (key string, value string, err error)
- func PathExists(fs afero.Fs, path string) bool
- func ReadBytes(reader io.Reader) ([]byte, error)
- func ReadBytesP(reader io.Reader) []byte
- func ReadDir(fs afero.Fs, path string) ([]os.FileInfo, error)
- func ReadDirP(fs afero.Fs, path string) []os.FileInfo
- func ReadEnv(fs afero.Fs, filenames ...string) (envMap map[string]string, err error)
- func ReadEnvFile(fs afero.Fs, filename string) (envMap map[string]string, err 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 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 RemovePackageName(symbolName string) string
- func RemovePackageNames(symbolNames []string) []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 RequiredString(hint string, key string, m map[string]any) (string, error)
- func RequiredStringP(hint string, key string, m map[string]any) string
- func SearchInText(text, query string) []string
- func SearchMultiple(text string, queries []string) []string
- func Set2Strings(set *hashset.Set) []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 StringArrayTrimSpace(stringArray []string) []string
- 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 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 TextLine2Array(line string) []string
- func ToJson(input any, pretty bool) (string, error)
- func ToJsonP(input any, pretty bool) 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 WalkDir(fs afero.Fs, ignoreFiles []string, dirPath string, include FileMatch, ...)
- func WorkingDirectory() (string, error)
- func WorkingDirectoryP() string
- func WriteEnv(fs afero.Fs, envMap map[string]string, filename 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)
- type Color
- 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](envsubst bool, yamlText string, cfgcfg *ConfigConfig, result *T, ...) (*T, *ConfigMetadata, error)
- func DecodeWithYamlP[T any](envsubst bool, yamlText string, cfgcfg *ConfigConfig, result *T, ...) (*T, *ConfigMetadata)
- type Console
- func (me Console) Begin()
- func (me Console) Blue(s ...any) Console
- func (me Console) Bluef(format string, a ...interface{}) Console
- func (me Console) Blueln(s ...any) Console
- func (me Console) Color(color Color, s ...any) Console
- func (me Console) Colorf(color Color, format string, a ...interface{}) Console
- func (me Console) Colorln(color Color, s ...any) Console
- func (me Console) Default(s ...any) Console
- func (me Console) Defaultf(format string, a ...interface{}) Console
- func (me Console) Defaultln(s ...any) Console
- func (me Console) End()
- func (me Console) Gray(s ...any) Console
- func (me Console) Grayf(format string, a ...interface{}) Console
- func (me Console) Grayln(s ...any) Console
- func (me Console) Green(s ...any) Console
- func (me Console) Greenf(format string, a ...interface{}) Console
- func (me Console) Greenln(s ...any) Console
- func (me Console) NewIndented() Console
- func (me Console) NewLine() Console
- func (me Console) Print(a ...interface{}) Console
- func (me Console) Printf(format string, a ...interface{}) Console
- func (me Console) Println(a ...interface{}) Console
- func (me Console) Red(s ...any) Console
- func (me Console) Redf(format string, a ...interface{}) Console
- func (me Console) Redln(s ...any) Console
- func (me Console) Yellow(s ...any) Console
- func (me Console) Yellowf(format string, a ...interface{}) Console
- func (me Console) Yellowln(s ...any) Console
- type ConsoleT
- type ErrorCallback
- type FileMatch
- func CompileGitIgnoreFile(fs afero.Fs, parent FileMatch, dirPath string) FileMatch
- func CompileGitIgnoreFileAndLines(fs afero.Fs, dirPath string, lines ...string) FileMatch
- func CompileMatchFile(fs afero.Fs, parent FileMatch, fpath string) FileMatch
- func CompileMatchFileAndLines(fs afero.Fs, fpath string, lines ...string) FileMatch
- func CompileMatchLines(parent FileMatch, lines ...string) FileMatch
- type FileMatchParser
- type FileMatchPattern
- type FileMatchPatternT
- type FileMatchT
- type WalkCallback
Constants ¶
This section is empty.
Variables ¶
var AppFs = afero.NewOsFs()
Functions ¶
func AbsPathWithP ¶
func AnyArrayToStringArray ¶
func DeepCopyMap ¶
func DurationHookFunc ¶
func EnsureDirExistsP ¶
func EnsureFileExistsP ¶
func EnsurePathExistsP ¶
func EnvDoubleQuoteEscape ¶
func EnvFilenamesOrDefault ¶
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 Executable ¶
func ExecutableP ¶
func ExecutableP() string
func ExpandHomePathP ¶
func ExtractTitle ¶
func FixJsonExtraEscapes ¶ added in v0.1.2
func FixJsonImports ¶ added in v0.1.2
func FixJsonQuotes ¶ added in v0.1.2
func FixJsonUnclosedBrackets ¶ added in v0.1.2
func IsAsciiSpace ¶
func IsIgnoredEnvLine ¶
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 LoadEnvMap ¶
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 OptionalString ¶
func OptionalStringP ¶
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 ParseEnvLine ¶
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 ReadEnvFile ¶
func RemoveDirP ¶
func RemoveFileP ¶
func RemovePackageName ¶
func RemovePackageNames ¶
func RenderAsTemplateArray ¶
func RenderAsTemplateArrayP ¶
func RenderWithTemplate ¶
func RenderWithTemplateP ¶
func RequiredString ¶
func SearchInText ¶
This function looks for a single query in the text, and returns up to 10 lines before and after the line where the query was found.
func SearchMultiple ¶
This function looks for multiple queries in the text. If the results are overlapping, they are merged.
func Set2Strings ¶
func Slice2Set ¶
func Slice2Set[T comparable](arr ...T) *hashset.Set
func SliceEquals ¶
func SliceEquals[T comparable](a []T, b []T) bool
func StringArrayP ¶
func StringArrayToAnyArray ¶
func StringArrayTrimSpace ¶
func StringArrayValue ¶
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 WalkDir ¶
func WalkDir(fs afero.Fs, ignoreFiles []string, dirPath string, include FileMatch, exclude FileMatch, includeCallback WalkCallback, excludeCallback WalkCallback, errorCallback ErrorCallback, )
func WorkingDirectory ¶
func WorkingDirectoryP ¶
func WorkingDirectoryP() string
func WriteFileIfNotFound ¶
WriteIfNotFound ...
func WriteFileIfNotFoundP ¶
func WriteFileLinesP ¶
WriteLines ...
func WriteFileText ¶
WriteText ...
func WriteFileTextIfNotFound ¶
func WriteFileTextIfNotFoundP ¶
WriteTextIfNotFound ...
Types ¶
type ConfigConfig ¶
type ConfigConfig struct {
DecodeHook mapstructure.DecodeHookFunc
// 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](envsubst bool, yamlText string, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata, error)
func DecodeWithYamlP ¶
func DecodeWithYamlP[T any](envsubst bool, yamlText string, cfgcfg *ConfigConfig, result *T, devault map[string]any) (*T, *ConfigMetadata)
type Console ¶
type Console = *ConsoleT
func NewConsole ¶
func NewConsole() Console
func (Console) NewIndented ¶
type ErrorCallback ¶
type FileMatch ¶
type FileMatch = *FileMatchT
func CompileGitIgnoreFile ¶
func CompileMatchFile ¶
CompileMatchFile uses an match file as the input, parses the lines out of the file and invokes the CompileMatchLines method.
func CompileMatchFileAndLines ¶
CompileMatchFileAndLines accepts a match file as the input, parses the lines out of the file and invokes the CompileMatchLines method with additional lines.
func CompileMatchLines ¶
CompileMatchLines accepts a variadic set of strings, and returns a FileMatchT instance which converts and appends the lines in the input to regexp.Regexp patterns held within the FileMatchT objects "patterns" field.
func (FileMatch) MatchesPath ¶
MatchesPath returns true if the given FileMatchT structure would target a given path string `f`.
func (FileMatch) MatchesPathHow ¶
func (me FileMatch) MatchesPathHow(f string) (bool, FileMatchPattern)
MatchesPathHow returns true, `pattern` if the given FileMatchT structure would target a given path string `f`. The FileMatchPatternT has the Line, LineNo fields.
type FileMatchParser ¶
type FileMatchParser interface {
MatchesPath(f string) bool
MatchesPathHow(f string) (bool, FileMatchPattern)
}
FileMatchParser is an interface with `MatchesPaths`.
type FileMatchPattern ¶
type FileMatchPattern = *FileMatchPatternT
type FileMatchPatternT ¶
FileMatchPatternT encapsulates a pattern and if it is a negated pattern.
type FileMatchT ¶
type FileMatchT struct {
// contains filtered or unexported fields
}
FileMatchT wraps a list of match pattern.
type WalkCallback ¶
type WalkCallback = func(filePath string)