utils

package
v1.28.2-0...-a792dfb Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToTar

func AddToTar(tw *tar.Writer, pth string, name string, filter func(h *tar.Header, size int64) (*tar.Header, error)) error

func AskForConfirmation

func AskForConfirmation(prompt string) bool

AskForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user. Typically, you should use fmt to print out a question before calling askForConfirmation. E.g. fmt.Println("WARNING: Are you sure? (yes/no)")

func AskForPassword

func AskForPassword(prompt string) (string, error)

func CopyDir

func CopyDir(src string, dst string) error

func CopyFile

func CopyFile(src string, dst string) error

func CopyFileStream

func CopyFileStream(src io.Reader, dst string) error

func DeepCopy

func DeepCopy(dst interface{}, src interface{}) error

func Exists

func Exists(path string) bool

func ExpandPath

func ExpandPath(p string) string

func ExtractTarGzFile

func ExtractTarGzFile(tarGzPath string, targetPath string) error

func ExtractTarGzStream

func ExtractTarGzStream(r io.Reader, targetPath string) error

func FindStrInSlice

func FindStrInSlice(a []string, s string) int

func FsCopyDir

func FsCopyDir(srcFs fs.FS, src string, dst string) error

func FsCopyFile

func FsCopyFile(srcFs fs.FS, src, dst string) error

func GetTermWidth

func GetTermWidth() int

func GetTmpBaseDir

func GetTmpBaseDir() string

func HashTarEntry

func HashTarEntry(dir string, name string) (string, error)

func IntMax

func IntMax(a, b int) int

IntMax returns the maximum integer provided

func IntMin

func IntMin(a, b int) int

func IsDirectory

func IsDirectory(path string) bool

func IsFile

func IsFile(path string) bool

func IsLaunchedByDebugger

func IsLaunchedByDebugger() bool

func NewErrorList

func NewErrorList(errors []error) *errorList

func ParseBoolOrFalse

func ParseBoolOrFalse(s *string) bool

func ParseEnvConfigSets

func ParseEnvConfigSets(prefix string) map[int]map[string]string

func RandomString

func RandomString(n int) string

func Sha256Bytes

func Sha256Bytes(data []byte) string

func Sha256String

func Sha256String(data string) string

func StrPtr

func StrPtr(s string) *string

func Touch

func Touch(path string) error

Types

type Inclusion

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

func NewInclusion

func NewInclusion() *Inclusion

func (*Inclusion) AddExclude

func (inc *Inclusion) AddExclude(typ string, value string)

func (*Inclusion) AddInclude

func (inc *Inclusion) AddInclude(typ string, value string)

func (*Inclusion) CheckIncluded

func (inc *Inclusion) CheckIncluded(l []InclusionEntry, excludeIfNotIncluded bool) bool

func (*Inclusion) HasType

func (inc *Inclusion) HasType(typ string) bool

type InclusionEntry

type InclusionEntry struct {
	Type  string
	Value string
}

type OnceByKey

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

func (*OnceByKey) Do

func (o *OnceByKey) Do(key string, cb func())

type OrderedMap

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

func (*OrderedMap) Get

func (s *OrderedMap) Get(v string) (interface{}, bool)

func (*OrderedMap) Has

func (s *OrderedMap) Has(v string) bool

func (*OrderedMap) ListKeys

func (s *OrderedMap) ListKeys() []string

func (*OrderedMap) ListValues

func (s *OrderedMap) ListValues() []interface{}

func (*OrderedMap) Set

func (s *OrderedMap) Set(k string, v interface{}) bool

type PrettyTable

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

func (*PrettyTable) AddRow

func (t *PrettyTable) AddRow(c ...string)

func (*PrettyTable) Render

func (t *PrettyTable) Render(limitWidths []int) string

func (*PrettyTable) SortRows

func (t *PrettyTable) SortRows(col int)

type Row

type Row []string

type ThreadSafeCache

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

func (*ThreadSafeCache) Get

func (c *ThreadSafeCache) Get(key string, f func() (interface{}, error)) (interface{}, error)

type ThreadSafeMultiCache

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

func (*ThreadSafeMultiCache) Get

func (c *ThreadSafeMultiCache) Get(cacheKey string, key string, f func() (interface{}, error)) (interface{}, error)

type WorkerPoolWithErrors

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

func NewDebuggerAwareWorkerPool

func NewDebuggerAwareWorkerPool(maxWorkers int) *WorkerPoolWithErrors

func NewWorkerPoolWithErrors

func NewWorkerPoolWithErrors(maxWorkers int) *WorkerPoolWithErrors

func (*WorkerPoolWithErrors) Errors

func (wp *WorkerPoolWithErrors) Errors() []error

func (*WorkerPoolWithErrors) Results

func (wp *WorkerPoolWithErrors) Results() []interface{}

func (*WorkerPoolWithErrors) StopWait

func (wp *WorkerPoolWithErrors) StopWait(restart bool) error

func (*WorkerPoolWithErrors) Submit

func (wp *WorkerPoolWithErrors) Submit(cb func() error)

func (*WorkerPoolWithErrors) SubmitWithResult

func (wp *WorkerPoolWithErrors) SubmitWithResult(cb func() (interface{}, error))

Directories

Path Synopsis
Package scanner provides a scanner and tokenizer for UTF-8-encoded text.
Package scanner provides a scanner and tokenizer for UTF-8-encoded text.

Jump to

Keyboard shortcuts

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