Documentation ¶
Index ¶
- func CombineRegexp(regexps ...*regexp.Regexp) *regexp.Regexp
- func CreateAndWriteTempFile(fileName string, data []byte) error
- func ExtractArchiveFile(archivePath string, outputDir string) error
- func FloatEquals(x1, x2, absTol float64) bool
- func JSONEquals(j1, j2 []byte) (bool, error)
- func LastNBytes(b []byte, n int) []byte
- func OpenTempFile(fileName string) (*os.File, error)
- func RemoveDuplicates[T comparable](items []T) []T
- func RemoveTempFilesDirectory() error
- func SHA256Hash(path string) (string, error)
- func Transform[T, R any](ts []T, fn func(T) R) []R
- func WriteFile(path string, contents []byte, executable bool) error
- type CommaSeparatedFlagsData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombineRegexp ¶
CombineRegexp creates a single regexp by joining the argument regexps together using the | operator. Each regexp is put into a separate non-capturing group before being combined.
func CreateAndWriteTempFile ¶
CreateAndWriteTempFile writes a file in the directory specified by writeBufferFolder.
This directory must be cleaned up with a call to RemoveTempFilesDirectory().
func ExtractArchiveFile ¶
ExtractArchiveFile extracts a .tar.gz / .tgz file located at archivePath, using outputDir as the root of the extracted files.
func FloatEquals ¶
FloatEquals compares two floats and returns true if they are both within absTol of each other, or are both NaN. Note that normally NaN != NaN, but we define it as true because it's convenient for comparing arrays and structs that contain floats.
func JSONEquals ¶
JSONEquals compares two byte sequences containing JSON data and returns true if 1) both j1 and j2 contain valid JSON data, and 2) the JSON objects that they represent are equal. If j1 or j2 contain invalid JSON data, an error is returned.
func LastNBytes ¶
LastNBytes returns the last n bytes from b. If len(b) <= n, b itself is returned, otherwise a copy of the bytes is returned. If n is negative, the function will panic
func RemoveDuplicates ¶
func RemoveDuplicates[T comparable](items []T) []T
RemoveDuplicates takes a slice and returns a new slice with only the unique elements from the input slice. Ordering of the elements in the returned slice corresponds is done according to the earliest index of each unique value in the input slice.
func RemoveTempFilesDirectory ¶
func RemoveTempFilesDirectory() error
func SHA256Hash ¶
SHA256Hash returns the SHA256 hashsum of a file.
Types ¶
type CommaSeparatedFlagsData ¶
func CommaSeparatedFlags ¶
func CommaSeparatedFlags(name string, values []string, usage string) CommaSeparatedFlagsData
CommaSeparatedFlags creates a struct which can be used with the Golang flag library, to allow passing a comma-separated list of strings as a single command-line argument.
Make sure to call InitFlag() on the returned struct before calling flag.Parse().
func (*CommaSeparatedFlagsData) InitFlag ¶
func (csl *CommaSeparatedFlagsData) InitFlag()
func (*CommaSeparatedFlagsData) Set ¶
func (csl *CommaSeparatedFlagsData) Set(values string) error
func (*CommaSeparatedFlagsData) String ¶
func (csl *CommaSeparatedFlagsData) String() string