util

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Quiet manages the display of NewSpinner, ProgressBar
	Quiet = false
)

Functions

func CacheDir added in v0.3.0

func CacheDir() string

CacheDir return cache dir path string

func Exec added in v0.3.0

func Exec(command string, args []string) (string, error)

Exec run the command

func Exists added in v0.3.0

func Exists(path string) (bool, error)

Exists check if path exists

func FetchConcurrently

func FetchConcurrently(urls []string, concurrency, wait int) (responses [][]byte, err error)

FetchConcurrently fetches concurrently

func FetchURL

func FetchURL(url string) ([]byte, error)

FetchURL returns HTTP response body

func FileWalk added in v0.3.0

func FileWalk(root string, targetFiles map[string]struct{}, walkFn func(r io.Reader, path string) error) error

FileWalk walks the file tree rooted at root

func FilterTargets added in v0.3.0

func FilterTargets(prefixPath string, targets map[string]struct{}) (map[string]struct{}, error)

FilterTargets filter targets

func GenWorkers

func GenWorkers(num, wait int) chan<- func()

GenWorkers generate workers

func GetDefaultLogDir

func GetDefaultLogDir() string

GetDefaultLogDir returns default log directory

func IsCommandAvailable added in v0.3.0

func IsCommandAvailable(name string) bool

IsCommandAvailable check if command is available.

func Major

func Major(osVer string) (majorVersion string)

Major returns major version

func SetLogger

func SetLogger(logToFile bool, logDir string, debug, logJSON bool) error

SetLogger set logger

func TrimSpaceNewline

func TrimSpaceNewline(str string) string

TrimSpaceNewline deletes space character and newline character(CR/LF)

func Unique added in v0.4.2

func Unique[T comparable](s []T) []T

Unique return unique elements

Types

type ProgressBar added in v0.3.0

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

ProgressBar has ProgressBar client

func PbStartNew added in v0.3.0

func PbStartNew(total int) *ProgressBar

PbStartNew creates a ProgressBar

func (*ProgressBar) Finish added in v0.3.0

func (p *ProgressBar) Finish()

Finish to exit the ProgressBar

func (*ProgressBar) Increment added in v0.3.0

func (p *ProgressBar) Increment()

Increment increments the ProgressBar

type Spinner added in v0.3.0

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

Spinner has Spinner client

func NewSpinner added in v0.3.0

func NewSpinner(suffix string) *Spinner

NewSpinner creates a Spinner

func (*Spinner) Start added in v0.3.0

func (s *Spinner) Start()

Start will start Spinner

func (*Spinner) Stop added in v0.3.0

func (s *Spinner) Stop()

Stop will stop the Spinner

Jump to

Keyboard shortcuts

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