util

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 39 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(number float64) float64

Abs abs()

func Add

func Add(m, n interface{}) int

func Addslashes

func Addslashes(str string) string

Addslashes addslashes()

func ArgStringToAryInterface

func ArgStringToAryInterface(d []string) []interface{}

func ArrayChunk

func ArrayChunk(s []interface{}, size int) [][]interface{}

ArrayChunk array_chunk()

func ArrayColumn

func ArrayColumn(input map[string]map[string]interface{}, columnKey string) []interface{}

ArrayColumn array_column()

func ArrayCombine

func ArrayCombine(s1, s2 []interface{}) map[interface{}]interface{}

ArrayCombine array_combine()

func ArrayFill

func ArrayFill(startIndex int, num uint, value interface{}) map[int]interface{}

ArrayFill array_fill()

func ArrayFlip

func ArrayFlip(m map[interface{}]interface{}) map[interface{}]interface{}

ArrayFlip array_flip()

func ArrayKeyExists

func ArrayKeyExists(key interface{}, m map[interface{}]interface{}) bool

ArrayKeyExists array_key_exists()

func ArrayKeyPluck

func ArrayKeyPluck(data []map[string]string, value, key string) map[string]string

func ArrayKeys

func ArrayKeys(elements map[interface{}]interface{}) []interface{}

ArrayKeys array_keys()

func ArrayMerge

func ArrayMerge(ss ...[]interface{}) []interface{}

ArrayMerge array_merge()

func ArrayMultiPluck added in v1.6.3

func ArrayMultiPluck(data []map[string]string, key string) map[string]map[string]string

func ArrayPad

func ArrayPad(s []interface{}, size int, val interface{}) []interface{}

ArrayPad array_pad()

func ArrayPluck

func ArrayPluck(data []map[string]string, value string) []string

func ArrayPop

func ArrayPop(s *[]interface{}) interface{}

ArrayPop array_pop() Pop the element off the end of slice

func ArrayPush

func ArrayPush(s *[]interface{}, elements ...interface{}) int

ArrayPush array_push() Push one or more elements onto the end of slice

func ArrayRand

func ArrayRand(elements []interface{}) []interface{}

ArrayRand array_rand()

func ArrayRandMap

func ArrayRandMap(elements []map[string]string) []map[string]string

ArrayRandMap 随即

func ArrayRemoveRepeatedElement added in v1.6.27

func ArrayRemoveRepeatedElement(arr []string) (newArr []string)

ArrayRemoveRepeatedElement 数组去重

func ArrayReverse

func ArrayReverse(s []interface{}) []interface{}

ArrayReverse array_reverse()

func ArrayShift

func ArrayShift(s *[]interface{}) interface{}

ArrayShift array_shift() Shift an element off the beginning of slice

func ArraySlice

func ArraySlice(s []interface{}, offset, length uint) []interface{}

ArraySlice array_slice()

func ArrayStringUniq added in v1.3.4

func ArrayStringUniq(arr []string) (newArr []string)

ArrayStringUniq 数组去重

func ArrayUnshift

func ArrayUnshift(s *[]interface{}, elements ...interface{}) int

ArrayUnshift array_unshift() Prepend one or more elements to the beginning of a slice

func ArrayValues

func ArrayValues(elements map[interface{}]interface{}) []interface{}

ArrayValues array_values()

func AryInterfaceToArgString

func AryInterfaceToArgString(d []interface{}) []string

func AryMapInterfaceToAryMapString

func AryMapInterfaceToAryMapString(d []map[string]interface{}) []map[string]string

func AryMapStringToAryMapInterface

func AryMapStringToAryMapInterface(d []map[string]string) []map[string]interface{}

func Base64Decode

func Base64Decode(str string) (string, error)

Base64Decode base64_decode()

func Base64Encode

func Base64Encode(str string) string

Base64Encode base64_encode()

func BaseConvert

func BaseConvert(number string, frombase, tobase int) (string, error)

BaseConvert base_convert()

func Basename

func Basename(path string) string

Basename basename()

func Bin2hex

func Bin2hex(str string) (string, error)

Bin2hex bin2hex()

func Bindec

func Bindec(str string) (string, error)

Bindec bindec()

func ByteReplace added in v1.6.23

func ByteReplace(s, old, new []byte, n int) []byte

func Ceil

func Ceil(value float64) float64

Ceil ceil()

func Checkdate

func Checkdate(month, day, year int) bool

Checkdate checkdate() Validate a Gregorian date

func Chmod

func Chmod(filename string, mode os.FileMode) error

Chmod chmod()

func Chown

func Chown(filename string, uid, gid int) error

Chown chown()

func Chr

func Chr(ascii int) string

Chr chr()

func ChunkSplit

func ChunkSplit(body string, chunklen uint, end string) string

ChunkSplit chunk_split()

func ConvertBson

func ConvertBson(items bson.D, item bson.E) bson.D

ConvertBson 构建 bson.D 查询数据

func Copy

func Copy(source, dest string) (bool, error)

Copy copy()

func Crc32

func Crc32(str string) uint32

Crc32 crc32()

func Date

func Date(format string, ts ...time.Time) string

Date date()

func DateTimeParse added in v1.5.1

func DateTimeParse(st string) (int, error)

DateTimeParse 时间解析

func DateToJulian

func DateToJulian(year int, month time.Month, day int) (dayNo int)

DateToJulian converts a date to a Julian day number.

func Day

func Day(s string, e string) ([]string, []int64)

Day 获取起止日期中的天 s,e Y-m-d

func DebugFormat

func DebugFormat(i interface{}) string

DebugFormat debug

func Decbin

func Decbin(number int64) string

Decbin decbin()

func Dechex

func Dechex(number int64) string

Dechex dechex()

func Decoct

func Decoct(number int64) string

Decoct decoct()

func Delete

func Delete(filename string) error

Delete delete()

func Dial added in v1.1.22

func Dial(addr string, timeout time.Duration) error

Dial dial 指定的端口,失败返回错误

func Die

func Die(status int)

Die die()

func Divide

func Divide(m, n interface{}) bool

查询是否被整除

func DomainStatic added in v1.6.22

func DomainStatic(p, v string) string

func Echo

func Echo(args ...interface{})

Echo echo

func Empty

func Empty(val interface{}) bool

Empty empty()

func Exec

func Exec(command string, output *[]string, returnVar *int) string

Exec exec() returnVar, 0: succ; 1: fail Return the last line from the result of the command. command format eg:

"ls -a"
"/bin/bash -c \"ls -a\""

func Exit

func Exit(status int)

Exit exit()

func Explode

func Explode(delimiter, str string) []string

Explode explode()

func ExtractIP

func ExtractIP(addr string) (string, error)

ExtractIP returns a real ip

func Fclose

func Fclose(handle *os.File) error

Fclose fclose()

func Fgetcsv

func Fgetcsv(handle *os.File, length int, delimiter rune) ([][]string, error)

Fgetcsv fgetcsv()

func FileExists

func FileExists(filename string) bool

FileExists file_exists()

func FileGetContents

func FileGetContents(filename string) (string, error)

FileGetContents file_get_contents()

func FilePutContents

func FilePutContents(filename string, data string, mode os.FileMode) error

FilePutContents file_put_contents()

func FileSize

func FileSize(filename string) (int64, error)

FileSize filesize()

func Filemtime

func Filemtime(filename string) (int64, error)

Filemtime filemtime()

func Floor

func Floor(value float64) float64

Floor floor()

func FormatDate added in v1.4.1

func FormatDate(str interface{}) string

func FormatDateTime added in v1.4.14

func FormatDateTime(str interface{}) string

func FormatDuring added in v1.5.1

func FormatDuring(t time.Time) string

FormatDuring 格式化秒

func FromYearWeek

func FromYearWeek(year, month, day int) (wyear, week int)

func FunctionName

func FunctionName(i interface{}) string

FunctionName ...

func GetAppRootPath

func GetAppRootPath() string

GetAppRootPath 获取应用程序根目录

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory 获取当前目录

func GetHourDiffer added in v1.5.1

func GetHourDiffer(startTime, endTime interface{}) int64

GetHourDiffer 获取相差时间

func GetIPs added in v1.1.22

func GetIPs() (ips []string)

GetIPs ...

func GetLocalIP added in v1.1.22

func GetLocalIP() (string, error)

GetLocalIP ...

func GetLocalMainIP added in v1.1.22

func GetLocalMainIP() (string, int, error)

GetLocalIP ...

func GetMacAddrs added in v1.1.22

func GetMacAddrs() (macAddrs []string)

GetMacAddrs ...

func GetMissingElement added in v1.2.20

func GetMissingElement(arr []int) int

func GetParentDirectory

func GetParentDirectory(dirctory string) string

GetParentDirectory 获取上级目录

func GetTimeZone added in v1.2.18

func GetTimeZone() *time.Location

GetTimeZone 获取时区

func Getcwd

func Getcwd() (string, error)

Getcwd getcwd()

func Getenv

func Getenv(varname string) string

Getenv getenv()

func GethostByAddr

func GethostByAddr(ipAddress string) (string, error)

GethostByAddr GethostByAddr() Get the Internet host name corresponding to a given IP address

func GethostByName

func GethostByName(hostname string) (string, error)

GethostByName GethostByName() Get the IPv4 address corresponding to a given Internet host name

func GethostByNamel

func GethostByNamel(hostname string) ([]string, error)

GethostByNamel GethostByNamel() Get a list of IPv4 addresses corresponding to a given Internet host name

func Gethostname

func Gethostname() (string, error)

Gethostname gethostname()

func Glob

func Glob(pattern string) ([]string, error)

Glob glob()

func HTMLEntityDecode

func HTMLEntityDecode(str string) string

HTMLEntityDecode html_entity_decode()

func HTTPBuildQuery

func HTTPBuildQuery(queryData url.Values) string

HTTPBuildQuery http_build_query()

func Hex2bin

func Hex2bin(data string) (string, error)

Hex2bin hex2bin()

func Hexdec

func Hexdec(str string) (int64, error)

Hexdec hexdec()

func Hour

func Hour(s string, e string) ([]string, []int64)

Day 获取起止日期中的小时 YmdH

func Htmlentities

func Htmlentities(str string) string

Htmlentities htmlentities()

func IP2long

func IP2long(ipAddress string) uint32

IP2long ip2long() IPv4

func ISOWeekday

func ISOWeekday(year int, month time.Month, day int) (weekday int)

ISOWeekday returns the ISO 8601 weekday number of given day. (1 = Mon, 2 = Tue,.. 7 = Sun)

This is different from Go's standard time.Weekday.

func Implode

func Implode(glue string, pieces []string) string

Implode implode()

func InArray

func InArray(needle interface{}, haystack interface{}) bool

InArray in_array() haystack supported types: slice, array or map

func InMultiArray added in v1.7.27

func InMultiArray(haystack interface{}, needle ...interface{}) bool

InMultiArray in_array() haystack supported types: slice, array or map

func InterfaceToString

func InterfaceToString(data []interface{}) (s []string)

func IsDir

func IsDir(filename string) (bool, error)

IsDir is_dir()

func IsFile

func IsFile(filename string) bool

IsFile is_file()

func IsNan

func IsNan(val float64) bool

IsNan is_nan()

func IsNumeric

func IsNumeric(val interface{}) bool

IsNumeric is_numeric() Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. In PHP hexadecimal (e.g. 0xf4c3b00c) is not supported, but IsNumeric is supported.

func IsReadable

func IsReadable(filename string) bool

IsReadable is_readable()

func IsWriteable

func IsWriteable(filename string) bool

IsWriteable is_writeable()

func JS

func JS(v string) template.JS

func JSONDecode

func JSONDecode(data []byte, val interface{}) error

JSONDecode json_decode()

func JSONEncode

func JSONEncode(val interface{}) ([]byte, error)

JSONEncode json_encode()

func JulianToDate

func JulianToDate(dayNo int) (year int, month time.Month, day int)

JulianToDate converts a Julian day number to a date.

func LcFirst

func LcFirst(str string) string

LcFirst LcFirst()

func Levenshtein

func Levenshtein(str1, str2 string, costIns, costRep, costDel int) int

Levenshtein levenshtein() costIns: Defines the cost of insertion. costRep: Defines the cost of replacement. costDel: Defines the cost of deletion.

func LocalListener added in v1.1.22

func LocalListener() net.Listener

LocalListener 随机一个本地端口,返回listener

func Long2ip

func Long2ip(properAddress uint32) string

Long2ip long2ip() IPv4

func Ltrim

func Ltrim(str string, characterMask ...string) string

Ltrim ltrim()

func MapInterfaceToMapString

func MapInterfaceToMapString(d map[string]interface{}) map[string]string

func MapStringToMapInterface

func MapStringToMapInterface(d map[string]string) map[string]interface{}

func MarshalHTML

func MarshalHTML(v interface{}) template.HTML

func MarshalJS

func MarshalJS(v interface{}) template.JS

func Max

func Max(nums ...float64) float64

Max max()

func MbStrlen

func MbStrlen(str string) int

MbStrlen mb_strlen()

func Md5

func Md5(str string) string

Md5 md5()

func Md5File

func Md5File(path string) (string, error)

Md5File md5_file()

func MemoryGetUsage

func MemoryGetUsage(realUsage bool) uint64

MemoryGetUsage memory_get_usage() return in bytes

func Min

func Min(nums ...float64) float64

Min min()

func Mkdir

func Mkdir(filename string, mode os.FileMode) error

Mkdir mkdir()

func MkdirAll

func MkdirAll(filename string, mode os.FileMode) error

MkdirAll 创建文件夹

func Month

func Month(d string) ([]string, []int64)

Month 获取当前月份前一年的月份 d Y-m-d

func MonthDate

func MonthDate(d string) (string, string)

MonthDate 获取当前日期的当月的第一天和最后一天

func MultiArray added in v1.2.25

func MultiArray(haystack interface{}) bool

判断二维数组里面是不是只有一条数据

func NewReplacer added in v1.6.23

func NewReplacer(endpoint string, values ...interface{}) string

func NextMonthDate

func NextMonthDate(d string) (string, string)

NextMonthDate 获取当前日期的下个月的第一天和最后一天

func Nl2br

func Nl2br(str string, isXhtml bool) string

Nl2br nl2br() \n\r, \r\n, \r, \n

func Now

func Now() time.Time

Now time.Now()

func NumberFormat

func NumberFormat(number float64, decimals uint, decPoint, thousandsSep string) string

NumberFormat number_format() decimals: Sets the number of decimal points. decPoint: Sets the separator for the decimal point. thousandsSep: Sets the thousands separator.

func Octdec

func Octdec(str string) (int64, error)

Octdec Octdec()

func Ord

func Ord(char string) int

Ord ord()

func Pack

func Pack(order binary.ByteOrder, data interface{}) (string, error)

Pack pack()

func ParseStr

func ParseStr(encodedString string, result map[string]interface{}) error

ParseStr parse_str() f1=m&f2=n -> map[f1:m f2:n] f[a]=m&f[b]=n -> map[f:map[a:m b:n]] f[a][a]=m&f[a][b]=n -> map[f:map[a:map[a:m b:n]]] f[]=m&f[]=n -> map[f:[m n]] f[a][]=m&f[a][]=n -> map[f:map[a:[m n]]] f[][]=m&f[][]=n -> map[f:[map[]]] // Currently does not support nested slice. f=m&f[a]=n -> error // This is not the same as PHP. a .[[b=c -> map[a___[b:c]

func ParseURL

func ParseURL(str string, component int) (map[string]string, error)

ParseURL parse_url() Parse a URL and return its components -1: all; 1: scheme; 2: host; 4: port; 8: user; 16: pass; 32: path; 64: query; 128: fragment

func Passthru

func Passthru(command string, returnVar *int)

Passthru passthru() returnVar, 0: succ; 1: fail

func Pathinfo

func Pathinfo(path string, options int) map[string]string

Pathinfo pathinfo() -1: all; 1: dirname; 2: basename; 4: extension; 8: filename Usage: Pathinfo("/home/go/path/src/php2go/php2go.go", 1|2|4|8)

func Pi

func Pi() float64

Pi pi()

func Ping added in v1.1.22

func Ping(host string, port int) error

Ping 调用http://ip:port/health 接口, 失败返回错误

func Pipeline

func Pipeline(str string) mongo.Pipeline

Pipeline gets aggregation pipeline from a string

func PrevMonthDate

func PrevMonthDate(d string) (string, string)

NextMonthDate 获取当前日期的上个月的第一天和最后一天

func Putenv

func Putenv(setting string) error

Putenv putenv() The setting, like "FOO=BAR"

func Quotemeta

func Quotemeta(str string) string

Quotemeta quotemeta()

func Rand

func Rand(min, max int) int

Rand rand() Range: [0, 2147483647]

func Random

func Random() string

Random 随机字符串

func Rawurldecode

func Rawurldecode(str string) (string, error)

Rawurldecode rawurldecode()

func Rawurlencode

func Rawurlencode(str string) string

Rawurlencode rawurlencode()

func Realpath

func Realpath(path string) (string, error)

Realpath realpath()

func Rename

func Rename(oldname, newname string) error

Rename rename()

func Round

func Round(value float64) float64

Round round()

func Rtrim

func Rtrim(str string, characterMask ...string) string

Rtrim rtrim()

func SetTimeZone added in v1.2.18

func SetTimeZone(zone string) *time.Location

SetTimeZone 设置时区

func Sha1

func Sha1(str string) string

Sha1 sha1()

func Sha1File

func Sha1File(path string) (string, error)

Sha1File sha1_file()

func SimilarText

func SimilarText(first, second string, percent *float64) int

SimilarText similar_text()

func Sleep

func Sleep(t int64)

Sleep sleep()

func Soundex

func Soundex(str string) string

Soundex soundex() Calculate the soundex key of a string.

func SplitString

func SplitString(p, split string, space bool) string

分割字符串 p 字符串, split 分隔符 , space 是否需要保留文字中的空格

func StartDate

func StartDate(wyear, week int) (year int, month time.Month, day int)

StartDate returns the starting date (Monday) of the given ISO 8601 week.

func Stat

func Stat(filename string) (os.FileInfo, error)

Stat stat()

func Static

func Static(p, v string) string

func StrLastChar added in v1.4.6

func StrLastChar(s string) string

StrLastChar 删除最后一个

func StrPad

func StrPad(str1, str2 string, i int) string

StrPad 填充字符串

func StrRepeat

func StrRepeat(input string, multiplier int) string

StrRepeat str_repeat()

func StrReplace

func StrReplace(search, replace, subject string, count int) string

StrReplace str_replace()

func StrRipos

func StrRipos(haystack, needle string, offset int) int

StrRipos StrRipos()

func StrRpos

func StrRpos(haystack, needle string, offset int) int

StrRpos StrRpos()

func StrShuffle

func StrShuffle(str string) string

StrShuffle str_shuffle()

func StrToInt

func StrToInt(str string, val int) int

StrToInt 字符串换数字

func StrToInt64

func StrToInt64(str string, val int64) int64

func StrToLower

func StrToLower(str string) string

StrToLower StrToLower()

func StrToTime

func StrToTime(format, strtime string) (int64, error)

StrToTime StrToTime() StrToTime("02/01/2006 15:04:05", "02/01/2016 15:04:05") == 1451747045 StrToTime("3 04 PM", "8 41 PM") == -62167144740

func StrToUpper

func StrToUpper(str string) string

StrToUpper StrToUpper()

func StrTrim

func StrTrim(str string) string

StrTrim 去除空格

func StrWordCount

func StrWordCount(str string) []string

StrWordCount str_word_count()

func StringToDate

func StringToDate(s string) (time.Time, error)

StringToDate attempts to parse a string into a time.Time type using a predefined list of formats. If no suitable format is found, an error is returned.

func Stripos

func Stripos(haystack, needle string, offset int) int

Stripos stripos()

func Stripslashes

func Stripslashes(str string) string

Stripslashes stripslashes()

func Strlen

func Strlen(str string) int

Strlen strlen()

func Strpos

func Strpos(haystack, needle string, offset int) int

Strpos strpos()

func Strrev

func Strrev(str string) string

Strrev strrev()

func Strstr

func Strstr(haystack string, needle string) string

Strstr strstr()

func Strtr

func Strtr(haystack string, params ...interface{}) string

Strtr strtr()

If the parameter length is 1, type is: map[string]string Strtr("baab", map[string]string{"ab": "01"}) will return "ba01" If the parameter length is 2, type is: string, string Strtr("baab", "ab", "01") will return "1001", a => 0; b => 1.

func Substr

func Substr(str string, start uint, length int) string

Substr substr()

func System

func System(command string, returnVar *int) string

System system() returnVar, 0: succ; 1: fail Returns the last line of the command output on success, and "" on failure.

func Tag

func Tag(i interface{}) string

Tag 数据标签

func Ternary

func Ternary(condition bool, trueVal, falseVal interface{}) interface{}

Ternary Ternary expression max := Ternary(a > b, a, b).(int)

func Time

func Time() int64

Time time()

func Timestamp

func Timestamp() int64

Timestamp 毫秒

func ToBool

func ToBool(i interface{}) bool

ToBool casts an interface to a bool type.

func ToBoolE

func ToBoolE(i interface{}) (bool, error)

ToBoolE casts an interface to a bool type.

func ToBoolSlice

func ToBoolSlice(i interface{}) []bool

ToBoolSlice casts an interface to a []bool type.

func ToBoolSliceE

func ToBoolSliceE(i interface{}) ([]bool, error)

ToBoolSliceE casts an interface to a []bool type.

func ToDuration

func ToDuration(i interface{}) time.Duration

ToDuration casts an interface to a time.Duration type.

func ToDurationE

func ToDurationE(i interface{}) (d time.Duration, err error)

ToDurationE casts an interface to a time.Duration type.

func ToDurationSlice

func ToDurationSlice(i interface{}) []time.Duration

ToDurationSlice casts an interface to a []time.Duration type.

func ToDurationSliceE

func ToDurationSliceE(i interface{}) ([]time.Duration, error)

ToDurationSliceE casts an interface to a []time.Duration type.

func ToFloat32

func ToFloat32(i interface{}) float32

ToFloat32 casts an interface to a float32 type.

func ToFloat32E

func ToFloat32E(i interface{}) (float32, error)

ToFloat32E casts an interface to a float32 type.

func ToFloat64

func ToFloat64(i interface{}) float64

ToFloat64 casts an interface to a float64 type.

func ToFloat64E

func ToFloat64E(i interface{}) (float64, error)

ToFloat64E casts an interface to a float64 type.

func ToInt

func ToInt(i interface{}) int

ToInt casts an interface to an int type.

func ToInt16

func ToInt16(i interface{}) int16

ToInt16 casts an interface to an int16 type.

func ToInt16E

func ToInt16E(i interface{}) (int16, error)

ToInt16E casts an interface to an int16 type.

func ToInt32

func ToInt32(i interface{}) int32

ToInt32 casts an interface to an int32 type.

func ToInt32E

func ToInt32E(i interface{}) (int32, error)

ToInt32E casts an interface to an int32 type.

func ToInt64

func ToInt64(i interface{}) int64

ToInt64 casts an interface to an int64 type.

func ToInt64E

func ToInt64E(i interface{}) (int64, error)

ToInt64E casts an interface to an int64 type.

func ToInt8

func ToInt8(i interface{}) int8

ToInt8 casts an interface to an int8 type.

func ToInt8E

func ToInt8E(i interface{}) (int8, error)

ToInt8E casts an interface to an int8 type.

func ToIntE

func ToIntE(i interface{}) (int, error)

ToIntE casts an interface to an int type.

func ToIntSlice

func ToIntSlice(i interface{}) []int

ToIntSlice casts an interface to a []int type.

func ToIntSliceE

func ToIntSliceE(i interface{}) ([]int, error)

ToIntSliceE casts an interface to a []int type.

func ToSlice

func ToSlice(i interface{}) []interface{}

ToSlice casts an interface to a []interface{} type.

func ToSliceE

func ToSliceE(i interface{}) ([]interface{}, error)

ToSliceE casts an interface to a []interface{} type.

func ToString

func ToString(i interface{}) string

ToString casts an interface to a string type.

func ToStringE

func ToStringE(i interface{}) (string, error)

ToStringE casts an interface to a string type.

func ToStringMap

func ToStringMap(i interface{}) map[string]interface{}

ToStringMap casts an interface to a map[string]interface{} type.

func ToStringMapBool

func ToStringMapBool(i interface{}) map[string]bool

ToStringMapBool casts an interface to a map[string]bool type.

func ToStringMapBoolE

func ToStringMapBoolE(i interface{}) (map[string]bool, error)

ToStringMapBoolE casts an interface to a map[string]bool type.

func ToStringMapE

func ToStringMapE(i interface{}) (map[string]interface{}, error)

ToStringMapE casts an interface to a map[string]interface{} type.

func ToStringMapInt

func ToStringMapInt(i interface{}) map[string]int

ToStringMapInt casts an interface to a map[string]int type.

func ToStringMapInt64

func ToStringMapInt64(i interface{}) map[string]int64

ToStringMapInt64 casts an interface to a map[string]int64 type.

func ToStringMapInt64E

func ToStringMapInt64E(i interface{}) (map[string]int64, error)

ToStringMapInt64E casts an interface to a map[string]int64{} type.

func ToStringMapIntE

func ToStringMapIntE(i interface{}) (map[string]int, error)

ToStringMapIntE casts an interface to a map[string]int{} type.

func ToStringMapString

func ToStringMapString(i interface{}) map[string]string

ToStringMapString casts an interface to a map[string]string type.

func ToStringMapStringE

func ToStringMapStringE(i interface{}) (map[string]string, error)

ToStringMapStringE casts an interface to a map[string]string type.

func ToStringMapStringSlice

func ToStringMapStringSlice(i interface{}) map[string][]string

ToStringMapStringSlice casts an interface to a map[string][]string type.

func ToStringMapStringSliceE

func ToStringMapStringSliceE(i interface{}) (map[string][]string, error)

ToStringMapStringSliceE casts an interface to a map[string][]string type.

func ToStringSlice

func ToStringSlice(i interface{}) []string

ToStringSlice casts an interface to a []string type.

func ToStringSliceE

func ToStringSliceE(i interface{}) ([]string, error)

ToStringSliceE casts an interface to a []string type.

func ToTime

func ToTime(i interface{}) time.Time

ToTime casts an interface to a time.Time type.

func ToTimeE

func ToTimeE(i interface{}) (tim time.Time, err error)

ToTimeE casts an interface to a time.Time type.

func ToUint

func ToUint(i interface{}) uint

ToUint casts an interface to a uint type.

func ToUint16

func ToUint16(i interface{}) uint16

ToUint16 casts an interface to a uint16 type.

func ToUint16E

func ToUint16E(i interface{}) (uint16, error)

ToUint16E casts an interface to a uint16 type.

func ToUint32

func ToUint32(i interface{}) uint32

ToUint32 casts an interface to a uint32 type.

func ToUint32E

func ToUint32E(i interface{}) (uint32, error)

ToUint32E casts an interface to a uint32 type.

func ToUint64

func ToUint64(i interface{}) uint64

ToUint64 casts an interface to a uint64 type.

func ToUint64E

func ToUint64E(i interface{}) (uint64, error)

ToUint64E casts an interface to a uint64 type.

func ToUint8

func ToUint8(i interface{}) uint8

ToUint8 casts an interface to a uint8 type.

func ToUint8E

func ToUint8E(i interface{}) (uint8, error)

ToUint8E casts an interface to a uint type.

func ToUintE

func ToUintE(i interface{}) (uint, error)

ToUintE casts an interface to a uint type.

func ToWeekDay added in v1.5.34

func ToWeekDay(t interface{}) string

func Touch

func Touch(filename string) (bool, error)

Touch touch()

func Trim

func Trim(str string, characterMask ...string) string

Trim trim()

func URLDecode

func URLDecode(str string) (string, error)

URLDecode urldecode()

func URLEncode

func URLEncode(str string) string

URLEncode urlencode()

func UcFirst

func UcFirst(str string) string

UcFirst UcFirst()

func UcWords

func UcWords(str string) string

UcWords UcWords()

func UnescapeString

func UnescapeString(v interface{}) string

func Uniqid

func Uniqid(prefix string) string

Uniqid uniqid()

func UnixTimeFormatDate

func UnixTimeFormatDate(str interface{}) string
func Unlink(filename string) error

Unlink unlink()

func Unpack

func Unpack(order binary.ByteOrder, data string) (interface{}, error)

Unpack unpack()

func Usleep

func Usleep(t int64)

Usleep usleep()

func VerifyEmail

func VerifyEmail(email string) bool

VerifyEmail 验证邮箱

func VerifyIPv4

func VerifyIPv4(address string) bool

VerifyIPv4 判断是否是否 ipv4 地址

func VerifyIPv6

func VerifyIPv6(address string) bool

VerifyIPv6 判断是否是 ipv6 地址

func VerifyPhone

func VerifyPhone(phone string) bool

VerifyPhone 验证电话号码是否正确

func VersionCompare

func VersionCompare(version1, version2, operator string) bool

VersionCompare version_compare() The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively. special version strings these are handled in the following order, (any string not found) < dev < alpha = a < beta = b < RC = rc < # < pl = p Usage: VersionCompare("1.2.3-alpha", "1.2.3RC7", '>=') VersionCompare("1.2.3-beta", "1.2.3pl", 'lt') VersionCompare("1.1_dev", "1.2any", 'eq')

func Wordwrap

func Wordwrap(str string, width uint, br string, cut bool) string

Wordwrap wordwrap()

func ZhCharToFirstPinyin

func ZhCharToFirstPinyin(p string) string

ZhCharToFirstPinyin 将中文转换成小写字母

func ZhCharToPinyin added in v1.6.11

func ZhCharToPinyin(p string) string

ZhCharToPinyin 将中文转换成小写字母

func ZipOpen

func ZipOpen(filename string) (*zip.ReadCloser, error)

ZipOpen zip_open()

Types

type URL added in v1.1.22

type URL struct {
	Scheme     string
	Opaque     string        // encoded opaque data
	User       *url.Userinfo // username and password information
	Host       string        // host or host:port
	Path       string        // path (relative paths may omit leading slash)
	RawPath    string        // encoded path hint (see EscapedPath method)
	ForceQuery bool          // append a query ('?') even if RawQuery is empty
	RawQuery   string        // encoded query values, without '?'
	Fragment   string        // fragment for references, without '#'
	HostName   string
	Port       string
	// contains filtered or unexported fields
}

URL wrap url.URL.

func ParseURLRaw added in v1.1.22

func ParseURLRaw(raw string) (*URL, error)

ParseURLRaw parses raw into URL.

func (*URL) Password added in v1.1.22

func (u *URL) Password() (string, bool)

Password gets password from URL.

func (*URL) Query added in v1.1.22

func (u *URL) Query() url.Values

Query parses RawQuery and returns the corresponding values. It silently discards malformed value pairs. To check errors use ParseQuery.

func (*URL) QueryBool added in v1.1.22

func (u *URL) QueryBool(field string, expect bool) (ret bool)

QueryBool returns provided field's value in bool if value is empty, expect returns

func (*URL) QueryDuration added in v1.1.22

func (u *URL) QueryDuration(field string, expect time.Duration) (ret time.Duration)

QueryDuration returns provided field's value in duration type. if value is empty, expect returns

func (*URL) QueryInt added in v1.1.22

func (u *URL) QueryInt(field string, expect int) (ret int)

QueryInt returns provided field's value in int type. if value is empty, expect returns

func (*URL) QueryInt64 added in v1.1.22

func (u *URL) QueryInt64(field string, expect int64) (ret int64)

QueryInt64 returns provided field's value in int64 type. if value is empty, expect returns

func (*URL) QueryString added in v1.1.22

func (u *URL) QueryString(field string, expect string) (ret string)

QueryString returns provided field's value in string type. if value is empty, expect returns

func (*URL) Username added in v1.1.22

func (u *URL) Username() string

Username gets username from URL.

Jump to

Keyboard shortcuts

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