Documentation
¶
Index ¶
- Constants
- func Between(s, from, to string) string
- func Contains(obj interface{}, v ...interface{}) bool
- func DeepContains(obj interface{}, v ...interface{}) bool
- func Download(url string, dest string) (err error)
- func FileSize(s uint64) string
- func FilterBlankString(vs []string) []string
- func FilterEmptyString(vs []string) []string
- func FilterInt(vs []int, f func(int) bool) []int
- func FilterString(vs []string, f func(string) bool) []string
- func HumanReadableDuration(diffSeconds int64) string
- func Index(s, substr string) int
- func IsBlank(s string) bool
- func IsDir(path string) bool
- func IsEmpty(s string) bool
- func IsExist(path string) bool
- func IsFile(path string) bool
- func IsIPv4(s string) bool
- func IsNotBlank(s string) bool
- func IsNotEmpty(s string) bool
- func LeftPad(s string, padStr string, length int) string
- func Len(s string) int
- func Map(vs []string, f func(string) string) []string
- func RightPad(s string, padStr string, length int) string
- func ToInt(s string) int
- func ToIntDv(s string, dv int) int
- func Trim(str string) string
- func TrimLeft(str string) string
- func TrimRight(str string) string
- func UUID() string
- func WildcardMatch(pattern, name string) (matched bool)
- func WildcardMatchSimple(pattern, name string) bool
- func ZeroFill(s string, length int) string
- type SysStatus
Constants ¶
const EmptyStr = ""
EmptyStr is the empty string const
const RegIPv4 = "(([2][5][0-5]|[2][0-4][0-9]|[1][0-9]{2}|[1-9][0-9]|[0-9])[.]){3}([2][5][0-5]|[2][0-4][0-9]|[1][0-9]{2}|[1-9][0-9]|[0-9])"
RegIPv4 is the IPv4 Regexp
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains(obj interface{}, v ...interface{}) bool
Contains tells an object is in a list or not
func DeepContains ¶
func DeepContains(obj interface{}, v ...interface{}) bool
DeepContains tells an object is in a list or not, but uses reflect.DeepEqual to determine the equality
func FilterBlankString ¶ added in v0.2.0
FilterBlankString removes blank strings in a string slice
func FilterEmptyString ¶ added in v0.2.0
FilterEmptyString removes empty strings in a string slice
func FilterString ¶ added in v0.2.0
FilterString filters a string slice with the function returns false
func HumanReadableDuration ¶ added in v0.3.0
HumanReadableDuration translates seconds into human-readable text
func Index ¶
Index return the location of a string in another long string, if it doesn't exist, returns -1 this function supports CJK characters
func IsBlank ¶
IsBlank tells a string is blank or not, a string with all white blanks would be considered as true
func Len ¶
Len returns the length of a string using rune, it's useful when getting the length of a string including CJK characters
func WildcardMatch ¶ added in v0.3.0
WildcardMatch - finds whether the text matches/satisfies the pattern string. supports '*' and '?' wildcards in the pattern string. unlike path.Match(), considers a path as a flat name space while matching the pattern. The difference is illustrated in the example here https://play.golang.org/p/Ega9qgD4Qz .
func WildcardMatchSimple ¶ added in v0.3.0
WildcardMatchSimple - finds whether the text matches/satisfies the pattern string. supports only '*' wildcard in the pattern. considers a file system path as a flat name space.
Types ¶
type SysStatus ¶ added in v0.3.0
type SysStatus struct {
Uptime string
NumGoroutine int
// General statistics.
MemAllocated string // bytes allocated and still in use
MemTotal string // bytes allocated (even if freed)
MemSys string // bytes obtained from system (sum of XxxSys below)
Lookups uint64 // number of pointer lookups
MemMallocs uint64 // number of mallocs
MemFrees uint64 // number of frees
// Main allocation heap statistics.
HeapAlloc string // bytes allocated and still in use
HeapSys string // bytes obtained from system
HeapIdle string // bytes in idle spans
HeapInuse string // bytes in non-idle span
HeapReleased string // bytes released to the OS
HeapObjects uint64 // total number of allocated objects
// Low-level fixed-size structure allocator statistics.
// Inuse is bytes used now.
// Sys is bytes obtained from system.
StackInuse string // bootstrap stacks
StackSys string
MSpanInuse string // mspan structures
MSpanSys string
MCacheInuse string // mcache structures
MCacheSys string
BuckHashSys string // profiling bucket hash table
GCSys string // GC metadata
OtherSys string // other system allocations
// Garbage collector statistics.
NextGC string // next run in HeapAlloc time (bytes)
LastGC string // last run in absolute time (ns)
PauseTotalNs string
PauseNs string // circular buffer of recent GC pause times, most recent at [(NumGC+255)%256]
NumGC uint32
}
SysStatus describes system runtime environment
func GetSysStatus ¶ added in v0.3.0
func GetSysStatus() *SysStatus
GetSysStatus returns runtime information