util

package
v0.14.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains added in v0.3.0

func Contains[T comparable](s []T, e T) bool

func Dedup added in v0.5.2

func Dedup[S ~[]E, E cmp.Ordered](s S) S

Dedup wraps slices.Sort and slices.Compact to deduplicate a slice.

func DownloadFile

func DownloadFile(ctx context.Context, uri string) (string, error)

DownloadFile downloads a file and returns a path to it in temporary storage.

func HashFile

func HashFile(downloadedFile string, digest hash.Hash) (string, error)

HashFile calculates the hash for a file and returns it as a hex string.

func MutateAndQuoteStringFromMap added in v0.9.0

func MutateAndQuoteStringFromMap(with map[string]string, input string) (string, error)

Given a string and a map, replace the variables in the string with quoted values in the map. Currently, an "if" statement in a melange config can only have quoted strings or ${{variables}} as comparision values with == and !=. If we want to be able to resolve an "if" that can be fed back into melange, we need to maintain that requirement, so all variables get quoted once replaced.

func MutateStringFromMap added in v0.5.0

func MutateStringFromMap(with map[string]string, input string) (string, error)

Given a string and a map, replace the variables in the string with values in the map

func ReverseSlice added in v0.3.0

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

func RightJoinMap added in v0.5.0

func RightJoinMap(left map[string]string, right map[string]string) map[string]string

Given a left and right map, perform a right join and return the result

Types

This section is empty.

Jump to

Keyboard shortcuts

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