Versions in this module Expand all Collapse all v0 v0.0.6 Jan 19, 2022 v0.0.5 Jan 19, 2022 v0.0.4 Sep 29, 2020 v0.0.3 Sep 29, 2020 v0.0.2 Sep 10, 2020 v0.0.1 Sep 7, 2020 Changes in this version + const Byte + const CR + const EByte + const GByte + const Is32Bit + const Is64Bit + const IsLinux + const IsMac + const IsWindows + const KByte + const LF + const MByte + const PByte + const StrCRLF + const StrLF + const StrR + const StrTB + const TB + const TByte + const VersionCompareEq + const VersionCompareGt + const VersionCompareLt + var BreakLine = []byte("\n") + var BreakLineString = StrLF + var DateFormatReplacer = strings.NewReplacer(datePatterns) + var DefaultMonitor = NewMonitor() + var ErrCmdNotRunning = errors.New(`command is not running`) + var ErrExitedByContext = errors.New(`Received an exit notification from the context`) + var ErrMd5Unmatched = errors.New("WARNING: MD5 Sums don't match") + var ErrNoHeaderContentLength = errors.New(`No Content-Length Provided`) + var MonitorEventEmptyFn = func(string) + var OnCmdExitError = func(params []string, err *exec.ExitError) + var StartTime = time.Now() + var TimeShortUnits = map[string]map[string]string + var TimeUnits = map[string]map[string]string + var UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1541.0 Safari/537.36" + func AbsURL(pageURL string, relURL string) string + func AddCSlashes(s string, b ...rune) string + func AddSlashes(s string, args ...rune) string + func AppendStr(strs []string, str string) []string + func Base64Decode(str string) (string, error) + func Base64Encode(str string) string + func Bool(i interface{}) bool + func ByteMd5(b []byte) string + func Bytes2readCloser(b []byte) io.ReadCloser + func Bytes2str(b []byte) string + func CallFunc(getFuncByName func(string) (interface{}, bool), funcName string, ...) ([]reflect.Value, error) + func CalledAtFileLine(skip int) string + func CamelCase(s string) string + func CheckPassword(rawPassword string, hashedPassword string, salt string, positions ...uint) bool + func CleanSpaceLine(b []byte) []byte + func CleanSpaceLineString(b string) string + func ClearHTMLAttr(src string) string + func CloseProcessFromCmd(cmd *exec.Cmd) error + func CloseProcessFromPid(pid int) (err error) + func CloseProcessFromPidFile(pidFile string) (err error) + func CmdIsRunning(cmd *exec.Cmd) bool + func CompareSliceStr(s1, s2 []string) bool + func CompareSliceStrU(s1, s2 []string) bool + func ConvDateFormat(format string) string + func Copy(src, dest string) error + func CopyDir(srcPath, destPath string, filters ...func(filePath string) bool) error + func CreateCmd(params []string, recvResult func([]byte) error) *exec.Cmd + func CreateCmdStr(command string, recvResult func([]byte) error) *exec.Cmd + func CreateCmdStrWithWriter(command string, writer ...io.Writer) *exec.Cmd + func CreateCmdWithWriter(params []string, writer ...io.Writer) *exec.Cmd + func Date(ti int64, format string) string + func DateFormat(format string, timestamp interface{}) (t string) + func DateFormatShort(timestamp interface{}) string + func DateParse(dateString, format string) (time.Time, error) + func DateS(ts string, format string) string + func DateT(t time.Time, format string) string + func Decode(data []byte, to interface{}, args ...string) error + func Dump(m interface{}, args ...bool) (r string) + func ElapsedMemory() (ret string) + func Encode(data interface{}, args ...string) ([]byte, error) + func ExecCmd(cmdName string, args ...string) (string, string, error) + func ExecCmdBytes(cmdName string, args ...string) ([]byte, []byte, error) + func ExecCmdDir(dir, cmdName string, args ...string) (string, string, error) + func ExecCmdDirBytes(dir, cmdName string, args ...string) ([]byte, []byte, error) + func Expand(template string, match map[string]string, subs ...string) string + func FetchFiles(client *http.Client, files []RawFile, header http.Header) error + func FetchFilesCurl(files []RawFile, curlOptions ...string) error + func FileExists(name string) bool + func FileMTime(file string) (int64, error) + func FileSize(file string) (int64, error) + func FixDirSeparator(fpath string) string + func Float2int(v interface{}) int + func Float2int64(v interface{}) int64 + func Float2uint(v interface{}) uint + func Float2uint64(v interface{}) uint64 + func Float32(i interface{}) float32 + func Float64(i interface{}) float64 + func FormatByte(args ...interface{}) string + func FormatBytes(args ...interface{}) string + func FormatPastTime(timestamp interface{}, args ...string) string + func FriendlyTime(d time.Duration, args ...interface{}) (r string) + func FuncFullPath(i interface{}) (pkgName string, objName string, funcName string) + func FuncName(i interface{}) string + func FuncPath(i interface{}) (pkgName string, objName string, funcName string) + func GetAllSubDirs(rootPath string) ([]string, error) + func GetGOPATHs() []string + func GetJSON(dat *string, s interface{}) error + func GetSrcPath(importPath string) (appPath string, err error) + func GobDecode(data []byte, to interface{}) error + func GobEncode(data interface{}) ([]byte, error) + func GonicCase(name string) string + func GrepFile(patten string, filename string) (lines []string, err error) + func HTML2JS(data []byte) []byte + func HTMLDecode(str string) string + func HTMLEncode(str string) string + func HTTPClientWithTimeout(timeout time.Duration, options ...HTTPClientOptions) *http.Client + func HTTPGet(client *http.Client, url string, header http.Header) (io.ReadCloser, error) + func HTTPGetBytes(client *http.Client, url string, header http.Header) ([]byte, error) + func HTTPGetJSON(client *http.Client, url string, v interface{}) error + func HTTPGetToFile(client *http.Client, url string, header http.Header, fileName string) error + func HTTPPost(client *http.Client, url string, body []byte, header http.Header) (io.ReadCloser, error) + func HTTPPostBytes(client *http.Client, url string, body []byte, header http.Header) ([]byte, error) + func HTTPPostJSON(client *http.Client, url string, body []byte, header http.Header) ([]byte, error) + func HasChinese(str string) bool + func HasTableAlias(alias string, sqlStr string, quotes ...string) (bool, error) + func Hash(str string) string + func HexStr2int(hexStr string) (int, error) + func HomeDir() (home string, err error) + func HumaneFileSize(s uint64) string + func InInt16Slice(v int16, sl []int16) bool + func InInt32Slice(v int32, sl []int32) bool + func InInt64Slice(v int64, sl []int64) bool + func InIntSlice(v int, sl []int) bool + func InInterfaceSlice(v interface{}, sl []interface{}) bool + func InSlice(v string, sl []string) bool + func InSliceIface(v interface{}, sl []interface{}) bool + func InStringSlice(v string, sl []string) bool + func InUint16Slice(v uint16, sl []uint16) bool + func InUint32Slice(v uint32, sl []uint32) bool + func InUint64Slice(v uint64, sl []uint64) bool + func InUintSlice(v uint, sl []uint) bool + func Int(i interface{}) int + func Int2HexStr(num int) (hex string) + func Int32(i interface{}) int32 + func Int64(i interface{}) int64 + func Int64SliceDiff(slice1, slice2 []int64) (diffslice []int64) + func IntSliceDiff(slice1, slice2 []int) (diffslice []int) + func IsASCIIUpper(r rune) bool + func IsAlpha(r rune) bool + func IsAlphaNumeric(r rune) bool + func IsChinese(str string) bool + func IsDir(dir string) bool + func IsEmail(email string) bool + func IsEmailRFC(email string) bool + func IsExist(path string) bool + func IsFile(filePath string) bool + func IsLetter(l uint8) bool + func IsLocalhost(host string) bool + func IsMultiLineText(text string) bool + func IsNumeric(r rune) bool + func IsSingleLineText(text string) bool + func IsSliceContainsInt64(sl []int64, i int64) bool + func IsSliceContainsStr(sl []string, str string) bool + func IsURL(url string) bool + func IsUpperLetter(r rune) bool + func IsUsername(username string) bool + func JSONDecode(data []byte, to interface{}) error + func JSONEncode(data interface{}, indents ...string) ([]byte, error) + func LeftPadZero(input string, padLength int) string + func Loop(ctx context.Context, exec func() error, duration time.Duration) error + func LowerCaseFirst(name string) string + func Ltrim(str string) string + func MakePassword(password string, salt string, positions ...uint) string + func MarshalStream(w io.Writer, m interface{}) error + func MaskString(v string, width ...float64) string + func Md5(str string) string + func Md5file(file string) string + func Monitor(rootDir string, callback *MonitorEvent, args ...func(string) bool) error + func NewCookie(name string, value string, args ...interface{}) *http.Cookie + func Nl2br(str string) string + func NowStr() string + func NumberFormat(number interface{}, precision int, separator ...string) string + func NumberTrim(number string, precision int, separator ...string) string + func NumberTrimZero(number string) string + func Offset(page uint, limit uint) uint + func PBKDF2Key(password, salt []byte, iter, keyLen int, hFunc ...func() hash.Hash) string + func ParseArgs(command string) (params []string) + func ParseFuncName(funcString string) (pkgName string, objName string, funcName string) + func PascalCase(s string) string + func PowInt(x int, y int) int + func RandFloat32() float32 + func RandFloat64() float64 + func RandInt(max int) int + func RandPerm(max int) []int + func RandRangeInt(min, max int) int + func RandRangeInt64(min, max int64) int64 + func RandStr(count int) (r string) + func RandomASCII(count uint) string + func RandomAlphaOrNumeric(count uint, letters, numbers bool) string + func RandomAlphabetic(count uint) string + func RandomAlphanumeric(count uint) string + func RandomCreateBytes(n int, alphabets ...byte) []byte + func RandomNumeric(count uint) string + func RandomSpec0(count uint, start, end int, letters, numbers bool, chars []rune, ...) string + func RandomSpec1(count uint, start, end int, letters, numbers bool) string + func RandomString(count uint) string + func RandomStringSpec0(count uint, set []rune) string + func RandomStringSpec1(count uint, set string) string + func RangeDownload(url string, saveTo string, args ...int) error + func ReadFile(filePath string) ([]byte, error) + func ReadFileS(filePath string) (string, error) + func ReadJSON(path string, s interface{}) error + func Readbuf(r io.Reader, length int) ([]byte, error) + func RemoveEOL(text string) string + func RemoveXSS(v string) (r string) + func RestoreTime(str string, args ...string) time.Time + func Reverse(s string) string + func Round(f float64, n int) float64 + func Rtrim(str string) string + func RunCmd(params []string, recvResult func([]byte) error) *exec.Cmd + func RunCmdStr(command string, recvResult func([]byte) error) *exec.Cmd + func RunCmdStrWithWriter(command string, writer ...io.Writer) *exec.Cmd + func RunCmdWithReaderWriter(params []string, reader io.Reader, writer ...io.Writer) *exec.Cmd + func RunCmdWithWriter(params []string, writer ...io.Writer) *exec.Cmd + func RunCmdWithWriterx(params []string, wait time.Duration, writer ...io.Writer) (cmd *exec.Cmd, err error, newOut *CmdStartResultCapturer, ...) + func SafeBase64Decode(str string) (string, error) + func SafeBase64Encode(str string) string + func Salt() string + func SaveFile(filePath string, b []byte) (int, error) + func SaveFileS(filePath string, s string) (int, error) + func SearchFile(filename string, paths ...string) (fullpath string, err error) + func SeekFileLines(filename string, callback func(string) error) (err error) + func SeekRangeNumbers(expr string, fn func(int) bool) + func SelfDir() string + func SelfPath() string + func SetJSON(s interface{}) (string, error) + func Sha1(str string) string + func Sha256(str string) string + func SliceChunk(slice []interface{}, size int) (chunkslice [][]interface{}) + func SliceDiff(slice1, slice2 []interface{}) (diffslice []interface{}) + func SliceFilter(slice []interface{}, a filtertype) (ftslice []interface{}) + func SliceInsert(slice, insertion []interface{}, index int) []interface + func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{}) + func SliceMerge(slice1, slice2 []interface{}) (c []interface{}) + func SlicePad(slice []interface{}, size int, val interface{}) []interface + func SliceRand(a []interface{}) (b interface{}) + func SliceRandList(min, max int) []int + func SliceRange(start, end, step int64) (intslice []int64) + func SliceReduce(slice []interface{}, a reducetype) (dslice []interface{}) + func SliceRemove(slice []interface{}, start int, args ...int) []interface + func SliceRemoveCallback(length int, callback func(int) func(bool) error) error + func SliceShuffle(slice []interface{}) []interface + func SliceSum(intslice []int64) (sum int64) + func SliceUnique(slice []interface{}) (uniqueslice []interface{}) + func SnakeCase(name string) string + func SplitHost(host string) (domain string, port string) + func StatDir(rootPath string, includeDir ...bool) ([]string, error) + func Str(i interface{}) string + func Str2bytes(s string) []byte + func StrIsASCIIUpper(s string) bool + func StrIsAlpha(s string) bool + func StrIsAlphaNumeric(s string) bool + func StrIsLetter(s string) bool + func StrIsNumeric(s string) bool + func StrIsUpperLetter(s string) bool + func StrRepeat(str string, times int) string + func StrReplace(str string, find string, to string) string + func StrToTime(str string, args ...string) (unixtime int) + func String(v interface{}) string + func StringSliceDiff(slice1, slice2 []string) (diffslice []string) + func StripSlashes(s string) string + func StripTags(src string) string + func Substr(s string, dot string, lengthAndStart ...int) string + func TarGz(srcDirPath string, destFilePath string) error + func TestReflect(v interface{}) + func TextLine(src string) string + func TitleCase(name string) string + func ToASCIIUpper(r rune) rune + func ToStr(value interface{}, args ...int) (s string) + func ToUpperLetter(r rune) rune + func Token(key string, val []byte, args ...string) string + func Token256(key string, val []byte, args ...string) string + func TotalPages(totalRows uint, limit uint) uint + func TotalRunTime() string + func Trim(str string) string + func URLDecode(str string) (string, error) + func URLEncode(str string) string + func URLSafeBase64(str string, encode bool) string + func Uint(i interface{}) uint + func Uint32(i interface{}) uint32 + func Uint64(i interface{}) uint64 + func Uint64SliceDiff(slice1, slice2 []uint64) (diffslice []uint64) + func UintSliceDiff(slice1, slice2 []uint) (diffslice []uint) + func UnTarGz(srcFilePath string, destDirPath string) ([]string, error) + func Unlink(file string) bool + func UnmarshalStream(r io.Reader, m interface{}, fn func()) error + func Unzip(srcPath, destPath string) error + func UpperCaseFirst(name string) string + func VersionCompare(a, b string) (ret int) + func VersionComparex(a, b string, op string) bool + func WithPrefix(strs []string, prefix string) []string + func WithSuffix(strs []string, suffix string) []string + func WriteFile(filename string, data []byte) error + func WriteJSON(path string, dat *string) error + func WritePidFile(pidFile string) error + func Zip(srcDirPath string, destFilePath string, args ...*regexp.Regexp) (n int64, err error) + type CmdChanReader struct + func NewCmdChanReader(timeouts ...time.Duration) *CmdChanReader + func (c *CmdChanReader) Close() + func (c *CmdChanReader) Debug(on bool) *CmdChanReader + func (c *CmdChanReader) Read(p []byte) (n int, err error) + func (c *CmdChanReader) Send(b []byte) *CmdChanReader + func (c *CmdChanReader) SendString(s string) *CmdChanReader + type CmdResultCapturer struct + Do func([]byte) error + func (this CmdResultCapturer) Write(p []byte) (n int, err error) + func (this CmdResultCapturer) WriteString(p string) (n int, err error) + type CmdStartResultCapturer struct + func NewCmdStartResultCapturer(writer io.Writer, duration time.Duration) *CmdStartResultCapturer + func (this CmdStartResultCapturer) Buffer() *bytes.Buffer + func (this CmdStartResultCapturer) Write(p []byte) (n int, err error) + func (this CmdStartResultCapturer) Writer() io.Writer + type DoOnce struct + func (u *DoOnce) CanSet(reqTag interface{}) bool + func (u *DoOnce) Release(reqTag interface{}) + func (u *DoOnce) Wait(reqTag interface{}) + type Durafmt struct + func ParseDuration(dinput time.Duration, args ...interface{}) *Durafmt + func ParseDurationString(input string, args ...interface{}) (*Durafmt, error) + func (d *Durafmt) Duration() time.Duration + func (d *Durafmt) String() string + type HTTPClientOptions func(c *http.Client) + type MonitorEvent struct + Channel chan bool + Chmod func(string) + Create func(string) + Debug bool + Delete func(string) + Modify func(string) + Rename func(string) + func NewMonitor() *MonitorEvent + func (m *MonitorEvent) AddDir(dir string) error + func (m *MonitorEvent) AddFile(file string) error + func (m *MonitorEvent) AddFilter(args ...func(string) bool) *MonitorEvent + func (m *MonitorEvent) Close() error + func (m *MonitorEvent) IsDir(path string) bool + func (m *MonitorEvent) Remove(fileOrDir string) error + func (m *MonitorEvent) SetFilters(args ...func(string) bool) *MonitorEvent + func (m *MonitorEvent) Watch(args ...func(string) bool) *MonitorEvent + func (m *MonitorEvent) Watcher() *fsnotify.Watcher + type NotFoundError struct + Message string + func (e NotFoundError) Error() string + type OrderlySafeMap struct + func NewOrderlySafeMap() *OrderlySafeMap + func (m *OrderlySafeMap) Delete(k interface{}) + func (m *OrderlySafeMap) Keys() []interface{} + func (m *OrderlySafeMap) Set(k interface{}, v interface{}) bool + func (m *OrderlySafeMap) Values(force ...bool) []interface{} + func (m *OrderlySafeMap) VisitAll(callback func(int, interface{}, interface{})) + type RawFile interface + Data func() []byte + Name func() string + RawUrl func() string + SetData func([]byte) + type RemoteError struct + Err error + Host string + func (e *RemoteError) Error() string + type SafeMap struct + func NewSafeMap() *SafeMap + func (m *SafeMap) Check(k interface{}) bool + func (m *SafeMap) Delete(k interface{}) + func (m *SafeMap) Get(k interface{}) interface{} + func (m *SafeMap) Items() map[interface{}]interface{} + func (m *SafeMap) Set(k interface{}, v interface{}) bool + type StrTo string + func (f StrTo) Bool() (bool, error) + func (f StrTo) Exist() bool + func (f StrTo) Float32() (float32, error) + func (f StrTo) Float64() (float64, error) + func (f StrTo) Int() (int, error) + func (f StrTo) Int64() (int64, error) + func (f StrTo) MustBool() bool + func (f StrTo) MustFloat32() float32 + func (f StrTo) MustFloat64() float64 + func (f StrTo) MustInt() int + func (f StrTo) MustInt64() int64 + func (f StrTo) MustUint() uint + func (f StrTo) MustUint64() uint64 + func (f StrTo) MustUint8() uint8 + func (f StrTo) String() string + func (f StrTo) Uint() (uint, error) + func (f StrTo) Uint64() (uint64, error) + func (f StrTo) Uint8() (uint8, error) + type Time struct + func NewTime(t time.Time) *Time + func (t Time) IsAfter(timestamp interface{}, agoDays int, units ...int) bool + func (t Time) IsAgo(timestamp interface{}, days int, units ...int) bool + func (t Time) IsFuture(timestamp interface{}, days int, units ...int) bool + func (t Time) IsThisMonth(timestamp interface{}) bool + func (t Time) IsThisYear(timestamp interface{}) bool + func (t Time) IsToday(timestamp interface{}) bool + func (t Time) ParseTimestamp(timestamp interface{}) time.Time + func (t Time) SubTimestamp(timestamp interface{}) time.Duration