Documentation
¶
Index ¶
- Constants
- Variables
- func AesDecrypt(data []byte, key []byte) ([]byte, error)
- func AesEncrypt(data []byte, key []byte) ([]byte, error)
- func AppendUniqueStr(strs []string, str string) []string
- func ArrayToString(A []int, denim string) string
- func At(at time.Time) time.Time
- func Authenticate(attemptedPassword, encryptedPassword, salt string) bool
- func Bytes2Str(b []byte) string
- func ClearSyncMap(m *SyncMap)
- func Concat(str ...string) string
- func Contains(array interface{}, val interface{}) (index int)
- func ContainsBool(array []bool, val bool) (index int)
- func ContainsComplex(array []complex128, val complex128) (index int)
- func ContainsFloat(array []float64, val float64) (index int)
- func ContainsInt(array []int64, val int64) (index int)
- func ContainsString(array []string, val string) (index int)
- func ContainsUint(array []uint64, val uint64) (index int)
- func Copy(src, dest string) error
- func Date(ti int64, format string) 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 Decrypt(cryptic, key []byte) ([]byte, error)
- func Div(n, b float64) float64
- func Encrypt(origData, key []byte) ([]byte, error)
- func EncryptedPassword(rawPwd string, salt string) string
- 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 ExternalIP() (res []string)
- func FetchFiles(client *http.Client, files []RawFile, header http.Header) error
- func FetchFilesCurl(files []RawFile, curlOptions ...string) error
- func FileMTime(file string) (int64, error)
- func FileSize(file string) (int64, error)
- func GenFixedLengthChineseChars(length int) string
- func GenRandomLengthChineseChars(start, end int) string
- func GenerateRandomCode() string
- func GenerateSalt() string
- func GetAllSubDirs(rootPath string) ([]string, error)
- func GetGOPATH() []string
- func GetIP(r *http.Request) string
- func HasText(source string) bool
- func HexStr2int(hexStr string) (int, error)
- func HttpCall(client *http.Client, method, url string, header http.Header, body io.Reader) (io.ReadCloser, error)
- 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, header http.Header, body []byte) (io.ReadCloser, error)
- func HttpPostJSON(client *http.Client, url string, body, v interface{}) error
- func HumaneBytes(s uint64, base float64, sizes []string) string
- func HumaneFileSize(s uint64) string
- func Int2HexStr(num int) (hex string)
- func InternalIP() string
- func IsBlank(source string) bool
- func IsDir(dir string) bool
- func IsExist(path string) bool
- func IsFile(filePath string) bool
- func MD5(origData string) string
- func NewTime(t float64) time.Time
- func Now() time.Time
- func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte
- func PKCS5Padding(cipher []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func PowInt(x int, y int) int
- func RandInt(start int, end int) int
- func RandInt64(start int64, end int64) int64
- func RandStr(len int) string
- func RandString(n int) string
- func Reverse(s []rune) []rune
- func SHA1(data []byte) []byte
- func StartsWith(str, prefix string, offset int) bool
- func StatDir(rootPath string, includeDir ...bool) ([]string, error)
- func Str2Bytes(s string) []byte
- func ToStr(value interface{}, args ...int) (s string)
- func TokenizeToStringArray(str, delimiters string, trimTokens, ignoreEmptyTokens bool) []*string
- func TokenizeToStringArray1(str, delimiters string) []*string
- func WriteFile(filename string, data []byte) error
- type ArgAny
- type ArgInt
- type ArgString
- type Browser
- type Duration
- type NotFoundError
- type NumberTime
- type OSInfo
- type RawFile
- type RemoteError
- type StrTo
- func (f StrTo) Exist() bool
- func (f StrTo) Float64() float64
- func (f StrTo) Hash() string
- func (f StrTo) Int() (int, error)
- func (f StrTo) Int64() (int64, error)
- func (f StrTo) MustInt() int
- func (f StrTo) MustInt64() int64
- func (f StrTo) MustUint8() uint8
- func (f StrTo) String() string
- func (f StrTo) Uint8() (uint8, error)
- type StringTime
- type SyncMap
- func (m *SyncMap) MyDelete(key interface{})
- func (m *SyncMap) MyLen() int64
- func (m *SyncMap) MyLoad(key interface{}) (value interface{}, ok bool)
- func (m *SyncMap) MyLoadOrStore(key, value interface{}) (actual interface{}, loaded bool)
- func (m *SyncMap) MyRange(f func(key, value interface{}) bool)
- func (m *SyncMap) MyStore(key, value interface{})
- type UserAgent
- func (p *UserAgent) Bot() bool
- func (p *UserAgent) Browser() (string, string)
- func (p *UserAgent) Engine() (string, string)
- func (p *UserAgent) Localization() string
- func (p *UserAgent) Mobile() bool
- func (p *UserAgent) Mozilla() string
- func (p *UserAgent) OS() string
- func (p *UserAgent) OSInfo() OSInfo
- func (p *UserAgent) Parse(ua string)
- func (p *UserAgent) Platform() string
- func (p *UserAgent) UA() string
Constants ¶
const ( Byte = 1 KByte = Byte * 1024 MByte = KByte * 1024 GByte = MByte * 1024 TByte = GByte * 1024 PByte = TByte * 1024 EByte = PByte * 1024 )
存储单元常数。
const EmptySpace = " "
EmptySpace
const EmptyString = ""
EmptyString
const TimePrecision = time.Microsecond
TimePrecision determines how precisely time is measured by this library. When serializing and deserialization tokens,time values are automatically truncated to this precision. See the time package's Truncate method for more detail
Variables ¶
var CallUserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1541.0 Safari/537.36"
var TimeFunc = time.Now
Functions ¶
func AesDecrypt ¶ added in v1.0.7
AesDecrypt 解密
func AesEncrypt ¶ added in v1.0.7
AesEncrypt 加密
func AppendUniqueStr ¶ added in v1.0.3
AppendUniqueStr 将字符串追加到数组中,且去重
func Authenticate ¶
*
- 对输入的密码进行验证 *
- @param attemptedPassword 待验证的密码
- @param encryptedPassword 密文
- @param salt 盐值
- @return 是否验证成功
func ClearSyncMap ¶
func ClearSyncMap(m *SyncMap)
func Contains ¶
func Contains(array interface{}, val interface{}) (index int)
Contains返回数组中val的索引位置,当为-1时代表不包含
func ContainsBool ¶
ContainsBool返回bool类型'val'在数组中的索引位置
func ContainsComplex ¶
func ContainsComplex(array []complex128, val complex128) (index int)
ContainsComplex返回complex128类型'val'在数组中的索引位置
func ContainsFloat ¶
ContainsFloat返回float64类型'val'在数组中的索引位置
func ContainsInt ¶
ContainsInt返回int64类型'val'在数组中的索引位置
func ContainsString ¶
ContainsString返回string类型'val'在数组中的索引位置
func ContainsUint ¶
ContainsUint返回uint64类型'val'在数组中的索引位置
func DateT ¶
Format time.Time struct to string MM - month - 01 M - month - 1, single bit DD - day - 02 D - day 2 YYYY - year - 2006 YY - year - 06 HH - 24 hours - 03 H - 24 hours - 3 hh - 12 hours - 03 h - 12 hours - 3 mm - minute - 04 m - minute - 4 ss - second - 05 s - second = 5
func ExecCmdBytes ¶
执行系统命令并返回stdout,以字节类型表示的stderr以及可能的错误.
func ExecCmdDir ¶
在给定目录中执行系统命令并返回stdout,字符串类型的stderr以及可能的错误.
func ExecCmdDirBytes ¶
在给定目录中执行系统命令,并以字节类型返回stdout,stderr,以及可能的错误.
func FetchFiles ¶
FetchFiles fetches files specified by the rawURL field in parallel.
func FetchFilesCurl ¶
FetchFiles uses command `curl` to fetch files specified by the rawURL field in parallel.
func GenFixedLengthChineseChars ¶
指定长度随机中文字符(包含复杂字符)
func GenRandomLengthChineseChars ¶
指定范围随机中文字符
func GetAllSubDirs ¶
返回给定根路径的所有子目录,返回值不包含给定的路径.
func HttpCall ¶
func HttpCall(client *http.Client, method, url string, header http.Header, body io.Reader) (io.ReadCloser, error)
HttpCall makes HTTP method call.
func HttpGet ¶
HttpGet gets the specified resource. ErrNotFound is returned if the server responds with status 404.
func HttpGetBytes ¶
HttpGetBytes gets the specified resource. ErrNotFound is returned if the server responds with status 404.
func HttpGetJSON ¶
HttpGetJSON gets the specified resource and mapping to struct. ErrNotFound is returned if the server responds with status 404.
func HttpGetToFile ¶
HttpGetToFile gets the specified resource and writes to file. ErrNotFound is returned if the server responds with status 404.
func HttpPost ¶
func HttpPost(client *http.Client, url string, header http.Header, body []byte) (io.ReadCloser, error)
HttpPost posts the specified resource. ErrNotFound is returned if the server responds with status 404.
func HttpPostJSON ¶
HttpPostJSON posts the specified resource with struct values, and maps results to struct. ErrNotFound is returned if the server responds with status 404.
func Now ¶
Now returns a new Time value using the current time. You can override Now by changing the value of TimeFunc
func PKCS5Padding ¶
func PKCS5UnPadding ¶
func StatDir ¶
通过深度优先收集给定目录的信息. 返回文件列表的一部分,并包括子目录(如果已启用); 当发生错误,或者给定的路径不是目录或不存在时,它将返回错误和nil数组。
返回值不包含给定的路径。 如果启用了子目录,则它们的后缀为'/'。
func TokenizeToStringArray ¶
根据分隔符进行分割处理,形成包路径数组.默认分割符为:",; \t\n"
func TokenizeToStringArray1 ¶
TokenizeToStringArray1
Types ¶
type Browser ¶
type Browser struct { // The name of the browser's engine. Engine string // The version of the browser's engine. EngineVersion string // The name of the browser. Name string // The version of the browser. Version string }
A struct containing all the information that we might be interested from the browser.
type Duration ¶
Duration be used toml unmarshal string time, like 1s, 500ms.
func NewDuration ¶
func (*Duration) UnmarshalText ¶
UnmarshalText unmarshal text to duration.
type NotFoundError ¶
type NotFoundError struct {
Message string
}
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type NumberTime ¶
func (NumberTime) MarshalJSON ¶
func (nt NumberTime) MarshalJSON() ([]byte, error)
func (*NumberTime) UnmarshalJSON ¶
func (nt *NumberTime) UnmarshalJSON(data []byte) error
type OSInfo ¶
type OSInfo struct { // Full name of the operating system. This is identical to the output of ua.OS() FullName string // Name of the operating system. This is sometimes a shorter version of the // operating system name, e.g. "Mac OS X" instead of "Intel Mac OS X" Name string // Operating system version, e.g. 7 for Windows 7 or 10.8 for Max OS X Mountain Lion Version string }
Represents full information on the operating system extracted from the user agent.
type RemoteError ¶
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string
type StringTime ¶
func (*StringTime) UnmarshalJSON ¶
func (st *StringTime) UnmarshalJSON(data []byte) error
type SyncMap ¶
func (*SyncMap) MyLoadOrStore ¶
type UserAgent ¶
type UserAgent struct {
// contains filtered or unexported fields
}
包含可以从User-Agent字符串中提取的所有信息。
func (*UserAgent) Browser ¶
Returns two strings. The first string is the name of the browser and the second one is the version of the browser.
func (*UserAgent) Engine ¶
Returns two strings. The first string is the name of the engine and the second one is the version of the engine.
func (*UserAgent) Localization ¶
Returns a string containing the localization.
func (*UserAgent) Mozilla ¶
Returns the mozilla version (it's how the User Agent string begins: "Mozilla/5.0 ...", unless we're dealing with Opera, of course).
func (*UserAgent) Parse ¶
Parse the given User-Agent string. After calling this function, the receiver will be setted up with all the information that we've extracted.