comm

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 29 Imported by: 0

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:

  1. A blank line matches no files, so it can serve as a separator for readability.

  2. A line starting with # serves as a comment. Put a backslash ("\") in front of the first hash for patterns that begin with a hash.

  3. Trailing spaces are ignored unless they are quoted with backslash ("\").

  4. 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".

  5. 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).

  6. 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).

  7. 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".

  8. A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".

  9. 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

Constants

This section is empty.

Variables

View Source
var AppFs = afero.NewOsFs()

Functions

func AbsPath

func AbsPath(_path string) (string, error)

func AbsPathP

func AbsPathP(_path string) string

func AbsPathWith

func AbsPathWith(_path string, workDir string) (string, error)

func AbsPathWithP

func AbsPathWithP(_path string, workDir string) string

func AnyArrayToStringArray

func AnyArrayToStringArray(anyArray []any) []string

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 DeepCopyMap

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

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 DurationHookFunc

func DurationHookFunc(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, error)

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 EnsurePathExists

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

func EnsurePathExistsP

func EnsurePathExistsP(fs afero.Fs, path string)

func EnvDoubleQuoteEscape

func EnvDoubleQuoteEscape(line string) string

func EnvExpandVariables

func EnvExpandVariables(v string, m map[string]string) string

func EnvFilenamesOrDefault

func EnvFilenamesOrDefault(filenames []string) []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 ExecGit

func ExecGit(fs afero.Fs, workDir string, args []string, trim bool) (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 ExtractMarkdownCodeBlocks

func ExtractMarkdownCodeBlocks(input string) (string, string, error)

func ExtractMarkdownCodeBlocksP

func ExtractMarkdownCodeBlocksP(input string) (string, string)

func ExtractMarkdownJsonBlocks

func ExtractMarkdownJsonBlocks(input string) (string, string, error)

func ExtractMarkdownJsonBlocksP

func ExtractMarkdownJsonBlocksP(input string) (string, string)

func ExtractTitle

func ExtractTitle(filePath 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 FixJson added in v0.1.2

func FixJson(input string, isGolang bool) string

func FixJsonExtraEscapes added in v0.1.2

func FixJsonExtraEscapes(input string) string

func FixJsonImports added in v0.1.2

func FixJsonImports(input string) string

func FixJsonQuotes added in v0.1.2

func FixJsonQuotes(input string) string

func FixJsonUnclosedBrackets added in v0.1.2

func FixJsonUnclosedBrackets(input string) string

func FormatDurationForConsole

func FormatDurationForConsole(d time.Duration) string

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 GetGitStatus

func GetGitStatus(fs afero.Fs, workDir string) (string, error)

func GetMapValue

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

func GetUnstagedFiles

func GetUnstagedFiles(fs afero.Fs, workDir string) ([]string, error)

func GitDirectory

func GitDirectory(fs afero.Fs, filePath string) string

func IsAsciiSpace

func IsAsciiSpace(s uint8) bool

func IsDarwin

func IsDarwin() bool

func IsDir

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

func IsDirP

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

func IsFile

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

func IsFileP

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

func IsGitInited

func IsGitInited(fs afero.Fs, workDir string) bool

func IsIgnoredEnvLine

func IsIgnoredEnvLine(line string) bool

func IsLinux

func IsLinux() 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 LoadEnvFile

func LoadEnvFile(fs afero.Fs, filename string) error

func LoadEnvMap

func LoadEnvMap(envMap map[string]string)

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 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 OptionalString

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

func OptionalStringArrayValue

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

func OptionalStringArrayValueP

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

func OptionalStringP

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 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 ParseEnvLine

func ParseEnvLine(line string, envMap map[string]string) (key string, value string, err error)

func PathExists

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

PathExists ...

func ReadBytes

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

ReadBytes ...

func ReadBytesP

func ReadBytesP(reader io.Reader) []byte

ReadBytesP ...

func ReadDir

func ReadDir(fs afero.Fs, path string) ([]os.FileInfo, error)

func ReadDirP

func ReadDirP(fs afero.Fs, path string) []os.FileInfo

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 ReadEnvFile

func ReadEnvFile(fs afero.Fs, filename string) (envMap map[string]string, err 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 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 RemovePackageName

func RemovePackageName(symbolName string) string

func RemovePackageNames

func RemovePackageNames(symbolNames []string) []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 RequiredString

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

func RequiredStringP

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

func SearchInText

func SearchInText(text, query string) []string

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

func SearchMultiple(text string, queries []string) []string

This function looks for multiple queries in the text. If the results are overlapping, they are merged.

func Set2Strings

func Set2Strings(set *hashset.Set) []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

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

func StringArray

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

func StringArrayP

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

func StringArrayToAnyArray

func StringArrayToAnyArray(stringArray []string) []any

func StringArrayTrimSpace

func StringArrayTrimSpace(stringArray []string) []string

func StringArrayValue

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

func StringArrayValueP

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

func StringMap

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

func StringMapP

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

func StringP

func StringP(hint string, v any) string

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 TextLine2Array

func TextLine2Array(line string) []string

func ToJson

func ToJson(input any, pretty bool) (string, error)

func ToJsonP

func ToJsonP(input any, pretty bool) 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 WalkDir

func WalkDir(fs afero.Fs,
	ignoreFiles []string,
	dirPath string,
	include FileMatch,
	exclude FileMatch,
	includeCallback WalkCallback,
	excludeCallback WalkCallback,
	errorCallback ErrorCallback,
)

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

Types

type Color

type Color int
const (
	DEFAULT_COLOR Color = iota
	RED
	GREEN
	YELLOW
	BLUE
	GRAY
)

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

func (me Console) Begin()

func (Console) Blue

func (me Console) Blue(s ...any) Console

func (Console) Bluef

func (me Console) Bluef(format string, a ...interface{}) Console

func (Console) Blueln

func (me Console) Blueln(s ...any) Console

func (Console) Color

func (me Console) Color(color Color, s ...any) Console

func (Console) Colorf

func (me Console) Colorf(color Color, format string, a ...interface{}) Console

func (Console) Colorln

func (me Console) Colorln(color Color, s ...any) Console

func (Console) Default

func (me Console) Default(s ...any) Console

func (Console) Defaultf

func (me Console) Defaultf(format string, a ...interface{}) Console

func (Console) Defaultln

func (me Console) Defaultln(s ...any) Console

func (Console) End

func (me Console) End()

func (Console) Gray

func (me Console) Gray(s ...any) Console

func (Console) Grayf

func (me Console) Grayf(format string, a ...interface{}) Console

func (Console) Grayln

func (me Console) Grayln(s ...any) Console

func (Console) Green

func (me Console) Green(s ...any) Console

func (Console) Greenf

func (me Console) Greenf(format string, a ...interface{}) Console

func (Console) Greenln

func (me Console) Greenln(s ...any) Console

func (Console) NewIndented

func (me Console) NewIndented() Console

func (Console) NewLine

func (me Console) NewLine() Console

func (Console) Print

func (me Console) Print(a ...interface{}) Console

func (Console) Printf

func (me Console) Printf(format string, a ...interface{}) Console

func (Console) Println

func (me Console) Println(a ...interface{}) Console

func (Console) Red

func (me Console) Red(s ...any) Console

func (Console) Redf

func (me Console) Redf(format string, a ...interface{}) Console

func (Console) Redln

func (me Console) Redln(s ...any) Console

func (Console) Yellow

func (me Console) Yellow(s ...any) Console

func (Console) Yellowf

func (me Console) Yellowf(format string, a ...interface{}) Console

func (Console) Yellowln

func (me Console) Yellowln(s ...any) Console

type ConsoleT

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

type ErrorCallback

type ErrorCallback = func(filePath string, err error)

type FileMatch

type FileMatch = *FileMatchT

func CompileGitIgnoreFile

func CompileGitIgnoreFile(fs afero.Fs, parent FileMatch, dirPath string) FileMatch

func CompileGitIgnoreFileAndLines

func CompileGitIgnoreFileAndLines(fs afero.Fs, dirPath string, lines ...string) FileMatch

func CompileMatchFile

func CompileMatchFile(fs afero.Fs, parent FileMatch, fpath string) FileMatch

CompileMatchFile uses an match file as the input, parses the lines out of the file and invokes the CompileMatchLines method.

func CompileMatchFileAndLines

func CompileMatchFileAndLines(fs afero.Fs, fpath string, lines ...string) FileMatch

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

func CompileMatchLines(parent FileMatch, lines ...string) FileMatch

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

func (me FileMatch) MatchesPath(f string) bool

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

type FileMatchPatternT struct {
	Pattern *regexp.Regexp
	Negate  bool
	LineNo  int
	Line    string
}

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)

Jump to

Keyboard shortcuts

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