Documentation ¶
Overview ¶
Package utils simply defines utility functions and types.
Index ¶
- Variables
- func CleanURL(str string) string
- func CompareStringLists(X, Y []string) []string
- func CompareStringListsInBoth(X, Y []string) []string
- func Contains(needle string, haystack []string) bool
- func Exec(dir string, bin string, args ...string) ([]byte, error)
- func PrometheusObserveTimeMilliseconds(h prometheus.Histogram, start time.Time)
- func SelectivelyExtractArchive(r io.Reader, prefix string, toExtract []string, maxFileSize int64) (map[string][]byte, error)
- type Stopper
- type TarReadCloser
- type XzReader
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCouldNotExtract occurs when an extraction fails. ErrCouldNotExtract = errors.New("utils: could not extract the archive") // ErrExtractedFileTooBig occurs when a file to extract is too big. ErrExtractedFileTooBig = errors.New("utils: could not extract one or more files from the archive: file too big") )
Functions ¶
func CompareStringLists ¶
CompareStringLists returns the strings that are present in X but not in Y.
func CompareStringListsInBoth ¶ added in v1.0.0
CompareStringListsInBoth returns the strings that are present in both X and Y.
func Contains ¶
Contains looks for a string into an array of strings and returns whether the string exists.
func PrometheusObserveTimeMilliseconds ¶ added in v1.0.0
func PrometheusObserveTimeMilliseconds(h prometheus.Histogram, start time.Time)
PrometheusObserveTimeMilliseconds observes the elapsed time since start, in milliseconds, on the specified Prometheus Histogram.
func SelectivelyExtractArchive ¶
func SelectivelyExtractArchive(r io.Reader, prefix string, toExtract []string, maxFileSize int64) (map[string][]byte, error)
SelectivelyExtractArchive extracts the specified files and folders from targz data read from the given reader and store them in a map indexed by file paths
Types ¶
type Stopper ¶
type Stopper struct {
// contains filtered or unexported fields
}
Stopper eases the graceful termination of a group of goroutines
func (*Stopper) Chan ¶
func (s *Stopper) Chan() chan struct{}
Chan returns the channel on which goroutines could listen to determine if they should stop. The channel is closed when Stop() is called.
type TarReadCloser ¶ added in v1.0.0
TarReadCloser embeds a *tar.Reader and the related io.Closer It is the caller's responsibility to call Close on TarReadCloser when done.
func (*TarReadCloser) Close ¶ added in v1.0.0
func (r *TarReadCloser) Close() error
type XzReader ¶ added in v1.0.0
type XzReader struct { io.ReadCloser // contains filtered or unexported fields }
XzReader is an io.ReadCloser which decompresses xz compressed data.
func NewXzReader ¶ added in v1.0.0
NewXzReader shells out to a command line xz executable (if available) to decompress the given io.Reader using the xz compression format and returns an *XzReader. It is the caller's responsibility to call Close on the XzReader when done.
Directories ¶
Path | Synopsis |
---|---|
Package errors defines error types that are used in several modules
|
Package errors defines error types that are used in several modules |
Package http provides utility functions for HTTP servers and clients.
|
Package http provides utility functions for HTTP servers and clients. |
Package types defines useful types that are used in database models.
|
Package types defines useful types that are used in database models. |