Documentation ¶
Index ¶
- func CopyDir(srcPath, destPath string) error
- func CopyFile(src, dest string) error
- func EnsureAbsolutePath(path, absoluteBase string) string
- func ExistsInSlice(target string, slice []string) bool
- func FileURLToPath(u *url.URL) (string, error)
- func GetDirectorySize(path string) (int64, error)
- func IsDir(dir string) (bool, error)
- func IsEmptyString(s string) bool
- func IsEqualSlice(target, source []string) bool
- func IsExist(path string) (bool, error)
- func IsFile(filePath string) (bool, error)
- func IsIPPrivate(ip net.IP) bool
- func IsInt64InSlice(target int64, slice []int64) bool
- func IsSliceInt64Eq(a, b []int64) bool
- func IsStringInSlice(target string, slice []string, insensitive ...bool) bool
- func Max(a, b int) int
- func MergeInto(dict map[string]interface{}, values ...interface{}) (map[string]interface{}, error)
- func Min(a, b int) int
- func NewSanitizedError(err error, oldnew ...string) error
- func NewStringURLSanitizedError(err error, unsanitizedURL string, usePlaceholder bool) error
- func NewStringURLSanitizer(unsanitizedURL string, usePlaceholder bool) *strings.Replacer
- func NewURLSanitizedError(err error, u *url.URL, usePlaceholder bool) error
- func NewURLSanitizer(u *url.URL, usePlaceholder bool) *strings.Replacer
- func NormalizeEOL(input []byte) []byte
- func PaginateSlice(list interface{}, page, pageSize int) interface{}
- func PathEscapeSegments(path string) string
- func RandomBytes(length int64) ([]byte, error)
- func RandomInt(limit int64) (int64, error)
- func RandomString(length int64) (string, error)
- func ReadAtMost(r io.Reader, buf []byte) (n int, err error)
- func Remove(name string) error
- func RemoveAll(name string) error
- func RemoveIDFromList(list []int64, id int64) ([]int64, bool)
- func Rename(oldpath, newpath string) error
- func ShellEscape(toEscape string) string
- func SplitStringAtByteN(input string, n int) (left, right string)
- func SplitStringAtRuneN(input string, n int) (left, right string)
- func StatDir(rootPath string, includeDir ...bool) ([]string, error)
- func StopTimer(t *time.Timer) bool
- func URLJoin(base string, elems ...string) string
- type Int64Slice
- type OptionalBool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDir ¶ added in v1.14.0
CopyDir copy files recursively from source to target directory. It returns error when error occurs in underlying functions.
func EnsureAbsolutePath ¶ added in v1.3.0
EnsureAbsolutePath ensure that a path is absolute, making it relative to absoluteBase if necessary
func ExistsInSlice ¶ added in v1.5.0
ExistsInSlice returns true if string exists in slice.
func FileURLToPath ¶ added in v1.15.0
FileURLToPath extracts the path information from a file://... url.
func GetDirectorySize ¶ added in v1.11.0
GetDirectorySize returns the disk consumption for a given path
func IsDir ¶ added in v1.14.0
IsDir returns true if given path is a directory, or returns false when it's a file or does not exist.
func IsEmptyString ¶ added in v1.7.0
IsEmptyString checks if the provided string is empty
func IsEqualSlice ¶ added in v1.5.0
IsEqualSlice returns true if slices are equal.
func IsExist ¶ added in v1.14.0
IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.
func IsFile ¶ added in v1.14.0
IsFile returns true if given path is a file, or returns false when it's a directory or does not exist.
func IsIPPrivate ¶ added in v1.15.7
IsIPPrivate for net.IP.IsPrivate.
func IsInt64InSlice ¶ added in v1.12.0
IsInt64InSlice sequential searches if int64 exists in slice.
func IsSliceInt64Eq ¶ added in v1.3.0
IsSliceInt64Eq returns if the two slice has the same elements but different sequences.
func IsStringInSlice ¶ added in v1.11.0
IsStringInSlice sequential searches if string exists in slice.
func NewSanitizedError ¶ added in v1.15.0
NewSanitizedError wraps an error and replaces all old, new string pairs in the message text.
func NewStringURLSanitizedError ¶ added in v1.15.0
NewStringURLSanitizedError wraps an error and replaces the url credential or removes them. If the url can't get parsed it gets replaced with a placeholder string.
func NewStringURLSanitizer ¶ added in v1.15.0
NewStringURLSanitizer creates a replacer for the url with the credential sanitized or removed. If the url can't get parsed it gets replaced with a placeholder string
func NewURLSanitizedError ¶ added in v1.15.0
NewURLSanitizedError wraps an error and replaces the url credential or removes them.
func NewURLSanitizer ¶ added in v1.15.0
NewURLSanitizer creates a replacer for the url with the credential sanitized or removed.
func NormalizeEOL ¶ added in v1.11.0
NormalizeEOL will convert Windows (CRLF) and Mac (CR) EOLs to UNIX (LF)
func PaginateSlice ¶ added in v1.14.0
func PaginateSlice(list interface{}, page, pageSize int) interface{}
PaginateSlice cut a slice as per pagination options if page = 0 it do not paginate
func PathEscapeSegments ¶ added in v1.8.0
PathEscapeSegments escapes segments of a path while not escaping forward slash
func RandomBytes ¶ added in v1.16.0
RandomBytes generates `length` bytes This differs from RandomString, as RandomString is limits each byte to have a maximum value of 63 instead of 255(max byte size)
func RandomString ¶ added in v1.15.0
RandomString generates a random alphanumerical string
func ReadAtMost ¶ added in v1.15.6
ReadAtMost reads at most len(buf) bytes from r into buf. It returns the number of bytes copied. n is only less then len(buf) if r provides fewer bytes. If EOF occurs while reading, err will be nil.
func Remove ¶ added in v1.13.0
Remove removes the named file or (empty) directory with at most 5 attempts.
func RemoveAll ¶ added in v1.2.0
RemoveAll removes the named file or (empty) directory with at most 5 attempts.
func RemoveIDFromList ¶ added in v1.16.5
RemoveIDFromList removes the given ID from the slice, if found. It does not preserve order, and assumes the ID is unique.
func ShellEscape ¶ added in v1.13.0
ShellEscape will escape the provided string. We can't just use go-shellquote here because our preferences for escaping differ from those in that we want:
* If the string doesn't require any escaping just leave it as it is. * If the string requires any escaping prefer double quote escaping * If we have ! or newlines then we need to use single quote escaping
func SplitStringAtByteN ¶ added in v1.15.0
SplitStringAtByteN splits a string at byte n accounting for rune boundaries. (Combining characters are not accounted for.)
func SplitStringAtRuneN ¶ added in v1.16.0
SplitStringAtRuneN splits a string at rune n accounting for rune boundaries. (Combining characters are not accounted for.)
func StatDir ¶ added in v1.14.0
StatDir gathers information of given directory by depth-first. It returns slice of file list and includes subdirectories if enabled; it returns error and nil slice when error occurs in underlying functions, or given path is not a directory or does not exist.
Slice does not include given path itself. If subdirectories is enabled, they will have suffix '/'.
Types ¶
type Int64Slice ¶ added in v1.3.0
type Int64Slice []int64
Int64Slice attaches the methods of Interface to []int64, sorting in increasing order.
func (Int64Slice) Len ¶ added in v1.3.0
func (p Int64Slice) Len() int
func (Int64Slice) Less ¶ added in v1.3.0
func (p Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶ added in v1.3.0
func (p Int64Slice) Swap(i, j int)
type OptionalBool ¶
type OptionalBool byte
OptionalBool a boolean that can be "null"
const ( // OptionalBoolNone a "null" boolean value OptionalBoolNone OptionalBool = iota // OptionalBoolTrue a "true" boolean value OptionalBoolTrue // OptionalBoolFalse a "false" boolean value OptionalBoolFalse )
func OptionalBoolOf ¶
func OptionalBoolOf(b bool) OptionalBool
OptionalBoolOf get the corresponding OptionalBool of a bool
func OptionalBoolParse ¶ added in v1.16.0
func OptionalBoolParse(s string) OptionalBool
OptionalBoolParse get the corresponding OptionalBool of a string using strconv.ParseBool
func (OptionalBool) IsFalse ¶ added in v1.3.0
func (o OptionalBool) IsFalse() bool
IsFalse return true if equal to OptionalBoolFalse
func (OptionalBool) IsNone ¶ added in v1.3.0
func (o OptionalBool) IsNone() bool
IsNone return true if equal to OptionalBoolNone
func (OptionalBool) IsTrue ¶ added in v1.3.0
func (o OptionalBool) IsTrue() bool
IsTrue return true if equal to OptionalBoolTrue