utils

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FileNotFoundError = fmt.Errorf("file not found")
)

Functions

func FileExists

func FileExists(f string) bool

func FsAbs

func FsAbs(f string) string

func GetCurrentDir

func GetCurrentDir() string

func HclLoad

func HclLoad(f string, cfg any) error

func IonLoad

func IonLoad(f string, cfg any) error

func IsIonFile

func IsIonFile(f string) bool

isIonFile detects if file is ion

func JsonDecode

func JsonDecode[T string | []byte](b T, v any) error

jsonDecode decodes json and returns pointer of R type passed e.g.1:

myTypePtr, err := jsonDecode(`{"fld1": "Val1"}`, MyType{})

e.g.2:

mapPtr, err := jsonDecode(`{"fld1": "Val1"}`, make(map[string]string))
m := *mapPtr
fmt.Println(m["fld1"])

func JsonLoad

func JsonLoad(f string, cfg any) error

func Loggers

func Loggers() (Debug *log.Logger, Warn *log.Logger, Info *log.Logger)

func MapJoin

func MapJoin(m map[string]string, kvGlue, glue string) string

func MapMerge

func MapMerge(m1, m2 map[string]string) map[string]string

mapMerge merges m1 with the value of m2 without modifying the original map. The values of m2 will override any duplicate values of m1

func Mkdir

func Mkdir(d string) error

func MkdirIfNotExists

func MkdirIfNotExists(d string) error

func RecurseDir

func RecurseDir(absDir string, cb func(absName string, file *os.File) error) error

RecurseDir loop throguh all files and directories recursively. cb is called back with the name and the open file

func RunScriptCode

func RunScriptCode(code string, args ...any) (map[string]any, error)

func ToEnvKey

func ToEnvKey(k string) string

func ToPropKey

func ToPropKey(k string) string

func Uncompress

func Uncompress(archiveFileName, dstDirName string) error

func Untgz

func Untgz(fileName, dir string) error

func Unzip

func Unzip(zipFileName, dstDirName string) error

func Zip

func Zip(srcDir string, writer io.Writer, include []string) error

Zip zips up files

Types

type CircularDependencyDetector

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

func NewCircularDependencyDetector

func NewCircularDependencyDetector() *CircularDependencyDetector

func (*CircularDependencyDetector) Clone

func (*CircularDependencyDetector) Push

func (c *CircularDependencyDetector) Push(item string) error

type PB

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

func NewProgressBar

func NewProgressBar(total int64) *PB

func (*PB) Done

func (o *PB) Done()

func (*PB) Set

func (o *PB) Set(v int64)

func (*PB) Wait

func (o *PB) Wait()

Jump to

Keyboard shortcuts

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