util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 19 Imported by: 0

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

func CacheDir() string

CacheDir return cache dir path string

func DefaultCacheDir added in v0.1.10

func DefaultCacheDir() string

DefaultCacheDir set default cache dir

func DeleteNil

func DeleteNil(errs []error) (new []error)

DeleteNil deletes nil in errs

func DeleteRecordNotFound

func DeleteRecordNotFound(errs []error) (new []error)

DeleteRecordNotFound deletes gorm.ErrRecordNotFound in errs

func DiffRedhat

func DiffRedhat(old, new *models.RedhatCVE, config config.RedhatWatchCve) (body string)

DiffRedhat returns the difference between the old and new CVE information

func Exec added in v0.1.10

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

Exec run the command

func Exists added in v0.1.10

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, apikey string) ([]byte, error)

FetchURL returns HTTP response body

func FileWalk added in v0.1.10

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

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

func IsCommandAvailable(name string) bool

IsCommandAvailable check if command is available.

func Major

func Major(osVer string) (majorVersion string)

Major returns major version

func SetCacheDir added in v0.1.10

func SetCacheDir(dir string)

SetCacheDir set cache dir path

func SetLogger

func SetLogger(logDir string, debug, logJSON bool)

SetLogger set logger

func StringInSlice added in v0.1.10

func StringInSlice(a string, list []string) bool

StringInSlice search within Slice by String

func TrimSpaceNewline

func TrimSpaceNewline(str string) string

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

Types

type Errors added in v0.2.0

type Errors []error

Errors has a set of errors that occurred in GORM

func (Errors) Add added in v0.2.0

func (errs Errors) Add(newErrors ...error) Errors

Add adds an error to a given slice of errors

func (Errors) Error added in v0.2.0

func (errs Errors) Error() string

Error takes a slice of all errors that have occurred and returns it as a formatted string

func (Errors) GetErrors added in v0.2.0

func (errs Errors) GetErrors() []error

GetErrors gets all errors that have occurred and returns a slice of errors (Error type)

type ProgressBar added in v0.1.10

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

ProgressBar has ProgressBar client

func PbStartNew added in v0.1.10

func PbStartNew(total int) *ProgressBar

PbStartNew creates a ProgressBar

func (*ProgressBar) Finish added in v0.1.10

func (p *ProgressBar) Finish()

Finish to exit the ProgressBar

func (*ProgressBar) Increment added in v0.1.10

func (p *ProgressBar) Increment()

Increment increments the ProgressBar

type Spinner added in v0.1.10

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

Spinner has Spinner client

func NewSpinner added in v0.1.10

func NewSpinner(suffix string) *Spinner

NewSpinner creates a Spinner

func (*Spinner) Start added in v0.1.10

func (s *Spinner) Start()

Start will start Spinner

func (*Spinner) Stop added in v0.1.10

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