Documentation ¶
Index ¶
- Variables
- func Abs(number float64) float64
- func Addslashes(str string) string
- func ArrayChunk(s []interface{}, size int) [][]interface{}
- func ArrayColumn(input map[string]map[string]interface{}, columnKey string) []interface{}
- func ArrayCombine(s1, s2 []interface{}) map[interface{}]interface{}
- func ArrayDiff(array1 []string, arrayOthers ...[]string) []string
- func ArrayFill(startIndex int, num uint, value interface{}) map[int]interface{}
- func ArrayFlip(m map[interface{}]interface{}) map[interface{}]interface{}
- func ArrayKeyExists(key interface{}, m map[interface{}]interface{}) bool
- func ArrayKeys(elements map[interface{}]interface{}) []interface{}
- func ArrayMerge(ss ...[]interface{}) []interface{}
- func ArrayPad(s []interface{}, size int, val interface{}) []interface{}
- func ArrayPop(s *[]interface{}) interface{}
- func ArrayPush(s *[]interface{}, elements ...interface{}) int
- func ArrayRand(elements []interface{}) []interface{}
- func ArrayReverse(s []interface{}) []interface{}
- func ArrayShift(s *[]interface{}) interface{}
- func ArraySlice(s []interface{}, offset, length uint) []interface{}
- func ArrayUnique(arr []string) []string
- func ArrayUniqueInt(arr []int) []int
- func ArrayUnshift(s *[]interface{}, elements ...interface{}) int
- func ArrayValues(elements map[interface{}]interface{}) []interface{}
- func Base64Decode(str string) (string, error)
- func Base64Encode(str string) string
- func BaseConvert(number string, frombase, tobase int) (string, error)
- func Basename(path string) string
- func Bin2hex(str string) (string, error)
- func Bindec(str string) (int64, error)
- func Binhex(str string) (string, error)
- func Bytes2ToInt64(b []byte) int64
- func Bytes4ToInt64(b []byte) int64
- func Bytes8ToInt64(buf []byte) int64
- func Ceil(value float64) float64
- func Checkdate(month, day, year int) bool
- func Chmod(filename string, mode os.FileMode) bool
- func Chown(filename string, uid, gid int) bool
- func Chr(ascii int) string
- func ChunkSplit(body string, chunklen uint, end string) string
- func Copy(source, dest string) (bool, error)
- func Crc32(str string) uint32
- func Date(format string, timestamp int64) string
- func DecHex(number int64) string
- func Decbin(number int64) string
- func Dechex(number int64) string
- func Decoct(number int64) string
- func Delete(filename string) error
- func Die(status int)
- func DiskFreeSpace(directory string) (uint64, error)
- func DiskTotalSpace(directory string) (uint64, error)
- func Echo(args ...interface{})
- func Empty(val interface{}) bool
- func Exec(command string, output *[]string, returnVar *int) string
- func Exit(status int)
- func Explode(delimiter, str string) []string
- func Fclose(handle *os.File) error
- func Fgetcsv(handle *os.File, length int, delimiter rune) ([][]string, error)
- func FileExists(filename string) bool
- func FileGetContents(filename string) (string, error)
- func FilePutContents(filename string, data string, mode os.FileMode) error
- func FileSize(filename string) (int64, error)
- func Filemtime(filename string) (int64, error)
- func Floor(value float64) float64
- func GetAgentServiceCheck(service *api.AgentServiceRegistration, remotePort int, checkPath string) *api.AgentServiceCheck
- func GetClient() *http.Client
- func GetClientIp(r *http.Request) (ip string)
- func GetFrpConfig() config.ClientCommonConf
- func GetHttpClient() *http.Client
- func GetInBoundIP() string
- func GetInterfaceToFloat(value interface{}) float64
- func GetInterfaceToInt(value interface{}) int
- func GetInterfaceToString(value interface{}) string
- func GetOutBoundIP() string
- func GetRequestParam(r *http.Request, key string, defaultValue string) string
- func Getcwd() (string, error)
- func Getenv(varname string) string
- func Gethostbyaddr(ipAddress string) (string, error)
- func Gethostbyname(hostname string) (string, error)
- func Gethostbynamel(hostname string) ([]string, error)
- func Gethostname() (string, error)
- func Glob(pattern string) ([]string, error)
- func HTMLEntityDecode(str string) string
- func HTTPBuildQuery(queryData url.Values) string
- func Hex2bin(h string) (str string, err error)
- func HexDec(str string) int64
- func HexDecode(code string, hex int64) int64
- func HexEncode(num, hex int64) string
- func Hexbin(str string) (string, error)
- func Hexdec(str string) (int64, error)
- func Htmlentities(str string) string
- func HttpDo(url string, param string, method string) ([]byte, error)
- func HttpGet(url string) ([]byte, error)
- func HttpJson(url string, data interface{}) ([]byte, error)
- func IP2long(ipAddress string) uint32
- func Implode(glue string, pieces []string) string
- func InArray(needle interface{}, haystack interface{}) bool
- func IntToBytes1(n int64) []byte
- func IntToBytes2(n int64) []byte
- func IntToBytes4(n int64) []byte
- func IntToBytes8(n int64) []byte
- func IsDir(filename string) (bool, error)
- func IsFile(filename string) bool
- func IsFrp() bool
- func IsNan(val float64) bool
- func IsNumeric(val interface{}) bool
- func IsReadable(filename string) bool
- func IsWriteable(filename string) bool
- func JSONDecode(data []byte, val interface{}) error
- func JSONEncode(val interface{}) ([]byte, error)
- func Lcfirst(str string) string
- func Levenshtein(str1, str2 string, costIns, costRep, costDel int) int
- func Long2ip(properAddress uint32) string
- func Ltrim(str string, characterMask ...string) string
- func Max(nums ...float64) float64
- func MbStrlen(str string) int
- func Md5(str string) string
- func Md5File(path string) (string, error)
- func MemoryGetPeakUsage(realUsage bool) uint64
- func MemoryGetUsage(realUsage bool) uint64
- func Min(nums ...float64) float64
- func Mkdir(filename string, mode os.FileMode) error
- func Nl2br(str string, isXhtml bool) string
- func NumberFormat(number float64, decimals uint, decPoint, thousandsSep string) string
- func Octdec(str string) (int64, error)
- func Ord(char string) int
- func Pack(format []string, args ...int64) string
- func ParseStr(encodedString string, result map[string]interface{}) error
- func ParseURL(str string, component int) (map[string]string, error)
- func Passthru(command string, returnVar *int)
- func Pathinfo(path string, options int) map[string]string
- func Pi() float64
- func Putenv(setting string) error
- func Quotemeta(str string) string
- func Rand(min, max int) int
- func RandStringRunes(l int, runes string) string
- func RandomBytes(length int) ([]byte, error)
- func RandomInt(min, max int) (int, error)
- func RandomString(l int) string
- func Rawurldecode(str string) (string, error)
- func Rawurlencode(str string) string
- func Realpath(path string) (string, error)
- func Rename(oldname, newname string) error
- func Round(value float64, precision int) float64
- func Rtrim(str string, characterMask ...string) string
- func SetAgentServiceProxyFrp(service *api.AgentServiceRegistration, remotePort int, checkPath string)
- func Sha1(str string) string
- func Sha1File(path string) (string, error)
- func SimilarText(first, second string, percent *float64) int
- func Sleep(t int64)
- func Soundex(str string) string
- func Stat(filename string) (os.FileInfo, error)
- func StrRepeat(input string, multiplier int) string
- func StrReplace(search, replace, subject string, count int) string
- func StrShuffle(str string) string
- func StrWordCount(str string) []string
- func Stripos(haystack, needle string, offset int) int
- func Stripslashes(str string) string
- func Strlen(str string) int
- func Strpos(haystack, needle string, offset int) int
- func Strrev(str string) string
- func Strripos(haystack, needle string, offset int) int
- func Strrpos(haystack, needle string, offset int) int
- func Strstr(haystack string, needle string) string
- func Strtolower(str string) string
- func Strtotime(format, strtime string) (int64, error)
- func Strtoupper(str string) string
- func Strtr(haystack string, params ...interface{}) string
- func Substr(str string, start uint, length int) string
- func System(command string, returnVar *int) string
- func Ternary(condition bool, trueVal, falseVal interface{}) interface{}
- func Time() int64
- func Touch(filename string) (bool, error)
- func Trim(str string, characterMask ...string) string
- func URLDecode(str string) (string, error)
- func URLEncode(str string) string
- func Ucfirst(str string) string
- func Ucwords(str string) string
- func Umask(mask int) int
- func Uniqid(prefix string) string
- func Unlink(filename string) error
- func Unpack(format []string, data string) []int64
- func Usleep(t int64)
- func VersionCompare(version1, version2, operator string) bool
- func Wordwrap(str string, width uint, br string, cut bool) string
- func ZipOpen(filename string) (*zip.ReadCloser, error)
- type Client
- type Connection
- type ConsulApi
- func (c *ConsulApi) GetClient() *api.Client
- func (c *ConsulApi) GetLock(key string, value string, ttl string) (lock *api.Lock, err error)
- func (c *ConsulApi) GetRegisterService(tag string, ip string, port int) *api.AgentServiceRegistration
- func (c *ConsulApi) RegisterService(service *api.AgentServiceRegistration, check *api.AgentServiceCheck) error
- func (c *ConsulApi) Service(service string) ([]*api.ServiceEntry, error)
- func (c *ConsulApi) ServiceDeregister(serviceID string) error
- func (c *ConsulApi) ServiceList(tag string) (map[string]*api.AgentService, error)
- func (c *ConsulApi) ServiceWatch(service string, handle watch.HandlerFunc)
- func (c *ConsulApi) WatchKeyToPath(key string, path string, t string)
- func (c *ConsulApi) WatchPathKey(path string, key string, t string)
- type Protocol
- func (p *Protocol) DecToHexString(decString []byte) (responseStr string)
- func (p *Protocol) HexStringToByte(hexString string) (responseByte []byte)
- func (p *Protocol) Pack(args ...int64) (ret []byte)
- func (p *Protocol) Pack16(args ...int64) (hString string)
- func (p *Protocol) UnPack(data []byte) []int64
- func (p *Protocol) UnPack16(hString string) (unIntList []int64)
- type Server
Constants ¶
This section is empty.
Variables ¶
var DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, }).DialContext, ForceAttemptHTTP2: true, MaxIdleConns: 100, MaxIdleConnsPerHost: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, DisableKeepAlives: false, }
var HexChar = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Functions ¶
func ArrayChunk ¶
func ArrayChunk(s []interface{}, size int) [][]interface{}
ArrayChunk array_chunk()
func ArrayColumn ¶
ArrayColumn array_column()
func ArrayCombine ¶
func ArrayCombine(s1, s2 []interface{}) map[interface{}]interface{}
ArrayCombine array_combine()
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 ArrayKeys ¶
func ArrayKeys(elements map[interface{}]interface{}) []interface{}
ArrayKeys array_keys()
func ArrayPad ¶
func ArrayPad(s []interface{}, size int, val interface{}) []interface{}
ArrayPad array_pad()
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 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 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 BaseConvert ¶
BaseConvert base_convert()
func ChunkSplit ¶
ChunkSplit chunk_split()
func Date ¶
Date date() Date("02/01/2006 15:04:05 PM", 1524799394) Note: the behavior is inconsistent with php's date function
func DiskFreeSpace ¶
DiskFreeSpace disk_free_space()
func DiskTotalSpace ¶
DiskTotalSpace disk_total_space()
func Exec ¶
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 FileGetContents ¶
FileGetContents file_get_contents()
func FilePutContents ¶
FilePutContents file_put_contents()
func GetAgentServiceCheck ¶ added in v1.1.1
func GetAgentServiceCheck(service *api.AgentServiceRegistration, remotePort int, checkPath string) *api.AgentServiceCheck
GetAgentServiceCheck 健康检查 checkPath!=tcp 走http 为空时 默认/health CONSUL_FRP=1 特殊使用 http 检查路径为 /{checkPath}/{service.ID} 注意绑定 http.HandleFunc("/health/", Health) 注意斜杠兼容 增加的server.ID
func GetClientIp ¶ added in v1.2.3
GetClientIp 获取客户端IP
func GetFrpConfig ¶ added in v1.1.1
func GetFrpConfig() config.ClientCommonConf
func GetHttpClient ¶ added in v1.2.2
GetHttpClient 建议使用连接池复用 或 使用 github.com/go-resty/resty/v2
func GetInterfaceToFloat ¶
func GetInterfaceToFloat(value interface{}) float64
GetInterfaceToFloat interface 转 float64
func GetInterfaceToInt ¶
func GetInterfaceToInt(value interface{}) int
GetInterfaceToInt interface 转 int
func GetInterfaceToString ¶
func GetInterfaceToString(value interface{}) string
GetInterfaceToString interface 转 string
func GetRequestParam ¶ added in v1.2.6
GetRequestParam 获取请求参数并带有默认值,同时去除空格
func Gethostbyaddr ¶
Gethostbyaddr gethostbyaddr() Get the Internet host name corresponding to a given IP address
func Gethostbyname ¶
Gethostbyname gethostbyname() Get the IPv4 address corresponding to a given Internet host name
func Gethostbynamel ¶
Gethostbynamel gethostbynamel() Get a list of IPv4 addresses corresponding to a given Internet host name
func HTMLEntityDecode ¶
HTMLEntityDecode html_entity_decode()
func HTTPBuildQuery ¶
HTTPBuildQuery http_build_query()
func InArray ¶
func InArray(needle interface{}, haystack interface{}) bool
InArray in_array() haystack supported types: slice, array or map
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 Levenshtein ¶
Levenshtein levenshtein() costIns: Defines the cost of insertion. costRep: Defines the cost of replacement. costDel: Defines the cost of deletion.
func MemoryGetPeakUsage ¶
MemoryGetPeakUsage memory_get_peak_usage() return in bytes
func MemoryGetUsage ¶
MemoryGetUsage memory_get_usage() return in bytes
func NumberFormat ¶
NumberFormat number_format() decimals: Sets the number of decimal points. decPoint: Sets the separator for the decimal point. thousandsSep: Sets the thousands' separator.
func ParseStr ¶
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 ¶
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 Pathinfo ¶
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 RandStringRunes ¶ added in v1.2.2
RandStringRunes - generate random string using random int
func RandomString ¶ added in v1.2.2
RandomString - Generate a random string of a-z chars with len = l
func SetAgentServiceProxyFrp ¶ added in v1.1.1
func SetAgentServiceProxyFrp(service *api.AgentServiceRegistration, remotePort int, checkPath string)
SetAgentServiceProxyFrp CONSUL_FRP_ADDR=必须子域名;CONSUL_FRP_PORT=7000;CONSUL_FRP_TOKEN=;CONSUL_FRP=1
func SimilarText ¶
SimilarText similar_text()
func StrReplace ¶
StrReplace str_replace()
func Strtotime ¶
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 Strtr ¶
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 System ¶
System system() returnVar, 0: succ; 1: fail Returns the last line of the command output on success, and "" on failure.
func Ternary ¶
func Ternary(condition bool, trueVal, falseVal interface{}) interface{}
Ternary Ternary expression max := Ternary(a > b, a, b).(int)
func VersionCompare ¶
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')
Types ¶
type Client ¶ added in v1.1.0
type Client struct {
// contains filtered or unexported fields
}
func (Client) GetAddress ¶ added in v1.1.0
func (a Client) GetAddress() string
type Connection ¶ added in v1.1.0
Connection 24字符串16进制 连接协议
func NewConnection ¶ added in v1.1.0
func NewConnection(clientIp string, clientPort int) *Connection
NewConnection 连接传入
func (*Connection) Id ¶ added in v1.1.0
func (c *Connection) Id() uint32
func (*Connection) ReleaseId ¶ added in v1.1.0
func (c *Connection) ReleaseId(id uint32)
ReleaseId 释放id
type ConsulApi ¶ added in v1.1.1
type ConsulApi struct {
// contains filtered or unexported fields
}
func (*ConsulApi) GetRegisterService ¶ added in v1.1.1
func (*ConsulApi) RegisterService ¶ added in v1.1.1
func (c *ConsulApi) RegisterService(service *api.AgentServiceRegistration, check *api.AgentServiceCheck) error
RegisterService 将服务注册到consul 健康检查 服务名称相同的才会返回多个
func (*ConsulApi) Service ¶ added in v1.1.1
func (c *ConsulApi) Service(service string) ([]*api.ServiceEntry, error)
Service 服务发现 服务名称相同的才会返回多个
func (*ConsulApi) ServiceDeregister ¶ added in v1.1.1
ServiceDeregister 注销服务
func (*ConsulApi) ServiceList ¶ added in v1.1.1
ServiceList 服务列表
func (*ConsulApi) ServiceWatch ¶ added in v1.1.1
func (c *ConsulApi) ServiceWatch(service string, handle watch.HandlerFunc)
ServiceWatch 服务监控
func (*ConsulApi) WatchKeyToPath ¶ added in v1.2.5
WatchKeyToPath watch key or keyprefix to path t 默认 目录监控 path 目录 + key 取文件部分 t=key path 目录 + key 取文件部分 t=source 转 t=file path=key t=file path是空=key 必须是文件(含路径)
type Protocol ¶
type Protocol struct {
Format []string
}
func (*Protocol) DecToHexString ¶
DecToHexString 10进制转16进制字符串
func (*Protocol) HexStringToByte ¶
HexStringToByte 16进制字符串转字节类型