utils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPointerValOrFalse

func BoolPointerValOrFalse(val *bool) bool

func Contains

func Contains[E comparable](s []E, v E) bool

Contains reports whether v is present in s.

func GetVulnerabilityTotalsPerSeverity

func GetVulnerabilityTotalsPerSeverity(vulnerabilities *[]models.Vulnerability) *models.VulnerabilityScanSummary

func Index

func Index[E comparable](s []E, v E) int

Index returns the index of the first occurrence of v in s, or -1 if not present.

func Int32PointerValOrEmpty

func Int32PointerValOrEmpty(val *int32) int32

func IntPointerValOrEmpty

func IntPointerValOrEmpty(val *int) int

func OmitEmpty

func OmitEmpty[T comparable](t T) *T

func PointerTo

func PointerTo[T any](value T) *T

func RunCommand

func RunCommand(cmd *exec.Cmd) ([]byte, error)

func RunCommandAndParseOutputLineByLine

func RunCommandAndParseOutputLineByLine(cmd *exec.Cmd, pfn, ecFn processFn) error

func StringKeyMapToArray

func StringKeyMapToArray[T any](m map[string]T) []T

func StringPointerValOrEmpty

func StringPointerValOrEmpty(val *string) string

func UnwrapErrorStrings

func UnwrapErrorStrings(err error) []string

UnwrapErrorStrings returns a slice of error strings by unwrapping err error. Returned slice is nil if provider err is nil. Slice with the original err as a single element is returned if err does not implement `Unwrap() error` or `Unwrap []error` interfaces. UnwrapErrorStrings does not perform recursive lookup, so only the top level err is unwrapped.

func UnwrapErrors

func UnwrapErrors(err error) []error

UnwrapErrors returns a slice of errors by unwrapping err error. Returned slice is nil if err is nil. Slice with the original err as a single element is returned if err does not implement `Unwrap() error` or `Unwrap []error` interfaces. UnwrapErrors does not perform recursive lookup, so only the top level err is unwrapped.

func ValueOrZero

func ValueOrZero[T any](ptr *T) T

ValueOrZero returns the value that the pointer ptr pointers to. It returns the zero value if ptr is nil.

Types

type CmdRunError

type CmdRunError struct {
	Cmd    *exec.Cmd
	Err    error
	Stdout []byte
	Stderr string
}

func (CmdRunError) Error

func (r CmdRunError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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