util

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepCopy

func DeepCopy(src, dest any) error

DeepCopy copies src to dest by using encoding/gob so its not that fast.

func DownloadFileHash

func DownloadFileHash(ctx context.Context, httpClient *http.Client, useragent string, progress func(progress ioprogress.ProgressData), canceler *cancel.HTTPRequestCanceller, filename string, url string, hash string, hashFunc hash.Hash, target io.WriteSeeker) (int64, error)

func IsFalse

func IsFalse(value string) bool

IsFalse returns true if value is "false", "0", "no" or "off" (case insensitive).

func IsFalseOrEmpty

func IsFalseOrEmpty(value string) bool

IsFalseOrEmpty returns true if value is empty or if IsFalse() returns true.

func IsTrue

func IsTrue(value string) bool

IsTrue returns true if value is "true", "1", "yes" or "on" (case insensitive).

func IsTrueOrEmpty

func IsTrueOrEmpty(value string) bool

IsTrueOrEmpty returns true if value is empty or if IsTrue() returns true.

func ParseUint32Range added in v0.7.0

func ParseUint32Range(value string) (uint32, uint32, error)

ParseUint32Range parses a uint32 range in the form "number" or "start-end". Returns the start number and the size of the range.

func PathExists

func PathExists(name string) bool

func PathIsWritable

func PathIsWritable(path string) bool

func SplitNTrimSpace

func SplitNTrimSpace(s string, sep string, n int, nilIfEmpty bool) []string

SplitNTrimSpace returns result of strings.SplitN() and then strings.TrimSpace() on each element. Accepts nilIfEmpty argument which if true, will return nil slice if s is empty (after trimming space).

func StringHasPrefix

func StringHasPrefix(value string, prefixes ...string) bool

StringHasPrefix returns true if value has one of the supplied prefixes.

func StringPrefixInSlice

func StringPrefixInSlice(key string, list []string) bool

StringPrefixInSlice returns true if any element in the list has the given prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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