Documentation ¶
Overview ¶
file 文件相关的一些辅助函数
str_convert 字符串,数字相互转换的一些辅助函数
Package of gutils common function.
Index ¶
- func AESDecrypt(in, key, iv []byte) ([]byte, error)
- func AESEncrypt(in, key, iv []byte) ([]byte, error)
- func Abs(number float64) float64
- func Addslashes(str string) string
- func Base64Decode(str string) (string, error)
- func Base64Encode(str string) string
- func Basename(path string) string
- func Bin2hex(src []byte) string
- func Bindec(str string) (string, error)
- func Ceil(value float64) float64
- func CheckPathExist(path string) bool
- func Chmod(filename string, mode os.FileMode) bool
- func Chown(name string, info os.FileInfo) error
- func Chr(ascii int) string
- func CopyFile(distName, srcName string) (w int64, err error)
- func Crc32(str string) uint32
- func Decbin(number int64) string
- func Empty(val interface{}) bool
- func Explode(delimiter, str string) []string
- func Fclose(handle *os.File) error
- func Fgetcsv(handle *os.File, delimiter rune, size ...int64) ([][]string, error)
- func FileChown(filename string, uid, gid int) bool
- 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 Filebase(file string) string
- func Fileline(file string, line int) string
- func Filemtime(filename string) (int64, error)
- func Float64ToStr(f64 float64) string
- func Floor(value float64) float64
- func Getcwd() (string, error)
- func Glob(pattern string) ([]string, error)
- func Gunzip(in []byte) ([]byte, error)
- func Gzip(in []byte) ([]byte, error)
- func HTMLEntities(str string) string
- func HTMLEntityDecode(str string) string
- func HTMLSpecialchars(str string) string
- func HTMLSpecialcharsDecode(str string) string
- func HTTPBuildQuery(queryData url.Values) string
- func Hash(mem []byte) uint64
- func Hex2bin(str string) []byte
- func IP2long(ipAddress string) uint32
- func Implode(glue string, pieces []string) string
- func Int64ToStr(i64 int64) string
- func IntToStr(n int) string
- func IsDir(filename string) (bool, error)
- func IsFile(filename string) bool
- func IsNumeric(v interface{}) bool
- func IsReadable(filename string) bool
- func IsWriteable(filename string) bool
- func Krand(size int, kind int) string
- func LcFirst(str string) string
- func LoadGobData(data interface{}, fileName string)
- 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(filename string) (string, error)
- func Min(nums ...float64) float64
- func Mkdir(filename string, mode os.FileMode) error
- func NewUUID() string
- func Ord(character string) rune
- func ParseURL(str string) (*url.URL, error)
- func Pathinfo(path string, options int) map[string]string
- func Rand(min, max int) int
- func RandInt64(min, max int64) int64
- func Rawurldecode(str string) (string, error)
- func Rawurlencode(str string) string
- func Realpath(path string) (string, error)
- func Rename(oldname, newname string) error
- func RndUuid() string
- func RndUuidMd5() string
- func Round(f float64, n int) float64
- func Rtrim(str string, characterMask ...string) string
- func RunShell(exeStr string) (string, error)
- func Sha1(str string) string
- func Sha1File(path string) (string, error)
- func Stat(filename string) (os.FileInfo, error)
- func StoreGobData(data interface{}, fileName string) error
- func StrJoin(sep string, str ...string) string
- func StrJoinByBuf(str ...string) string
- func StrRepeat(input string, multiplier int) string
- func StrReplace(search, replace, subject string, count int) string
- func StrShuffle(str string) string
- func StrToFloat64(str string) float64
- func StrToInt(s string) int
- func StrToInt64(s string) int64
- func Stripos(haystack, needle string) int
- func Stripslashes(str string) string
- func Strlen(str string) int
- func Strpos(haystack, needle string) int
- func Strripos(haystack, needle string) int
- func Strrpos(haystack, needle string) int
- func Strstr(haystack string, needle string) string
- func Strtolower(str string) string
- func Strtoupper(str string) string
- func Substr(str string, start uint, length int) string
- 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 Uniqid(prefix string) string
- func Unlink(filename string) error
- func Uuid() string
- func Xss(str string) string
- func XssUnescape(str string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESEncrypt ¶
AESEncrypt aes encrypt []byte. key = "abcdefghijklmnopqrstuvwxyz123456" iv = "0123456789ABCDEF"
func Chown ¶
Chown 清空文件并保持文件权限不变,并非linux chown操作 Empty the file and keep the file permissions unchanged not the linux chown operation
func Chr ¶
================str chr,ord func====================== Chr returns a one-character string containing the character specified by ascii go1.15 return string(rune(ascii))
func Explode ¶
=================str explode,implode,strlen================ Explode returns an slice of strings, each of which is a substring of str formed by splitting it on boundaries formed by the string delimiter.
func Fgetcsv ¶
Fgetcsv fgetcsv() 默认当文件大小大于10MB逐行读取内容,否则一次性读取内容 第三个参数可以指定逐行读取的最大文件大小,单位字节 1MB = 1 << 20
func FileGetContents ¶
FileGetContents file_get_contents()
func FilePutContents ¶
FilePutContents file_put_contents()
func Float64ToStr ¶
Float64ToStr float64 to string 'e' (-d.dddde±dd,十进制指数)
func Glob ¶
Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the same as in Match. The pattern may describe hierarchical names such as /usr/*/bin/ed (assuming the Separator is '/'). Glob ignores file system errors such as I/O errors reading directories. The only possible returned error is ErrBadPattern, when pattern is malformed.
func HTMLEntityDecode ¶
HTMLEntityDecode html_entity_decode()
func HTMLSpecialchars ¶
=====================html special characters================ HTMLSpecialchars converts special characters to HTML entities
func HTMLSpecialcharsDecode ¶
HTMLSpecialcharsDecode converts special HTML entities back to characters
func HTTPBuildQuery ¶
HTTPBuildQuery http_build_query() url a=1&b=2
func Implode ¶
Implode returns a string containing a string representation of all the slice elements in the same order, with the glue string between each element.
func IntToStr ¶
================str,int,int64,float64 conv func======================= IntToStr int-->string
func IsNumeric ¶
func IsNumeric(v interface{}) bool
IsNumeric 判断v是否是一个数字类型,php is_numeric(num) 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 Krand ¶
================str krand func=========== Krand 根据kind生成不同风格的指定区间随机字符串 纯数字kind=0,小写字母kind=1 大写字母kind=2,数字+大小写字母kind=3
func LoadGobData ¶
func LoadGobData(data interface{}, fileName string)
LoadGobData 将gob写入的内容,载入到data中
func Md5 ¶
==============str md5,md5File,sha1,crc32,bin2hex,hex2bin,hash func======= Other advanced functions, please see the go-god/crypto package md5 func
func NewUUID ¶
func NewUUID() string
=================uuid,rnduuid,uniqid func==================== NewUUID 通过随机数的方式生成uuid 如果rand.Read失败,就按照当前时间戳+随机数进行md5方式生成 该方式生成的uuid有可能存在重复值 返回格式:7999b726-ca3c-42b6-bda2-259f4ac0879a
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 Rawurlencode ¶
Rawurlencode rawurlencode(str) Rawurlencode is URL-encode according to RFC 3986. Rawurlencode is identical to URLEncode except that it does not escape space to +.
func RndUuid ¶
func RndUuid() string
RndUuid 基于时间ns和随机数实现唯一的uuid 在单台机器上是不会出现重复的uuid 如果要在分布式的架构上生成不重复的uuid 只需要在rndStr的前面加一些自定义的字符串 返回格式:eba1e8cd-0460-4910-49c6-44bdf3cf024d
func StoreGobData ¶
StoreGobData store gob data
func StrReplace ¶
StrReplace str_replace()
func Stripos ¶
Stripos find position of the first occurrence of a case-insensitive substring in a string
func Strpos ¶
=================str strpos,Strrpos,stripos,Strripos func==================== Strpos find position of first occurrence of string in a string It's multi-byte safe. return -1 if can not find the substring
func Strripos ¶
Strripos find the position of the last occurrence of a case-insensitive substring in a string
func Strtolower ¶
Strtolower strtolower(str) makes a string lowercase
func Strtoupper ¶
Strtoupper strtoupper(str) makes a string uppercase
func URLDecode ¶
URLDecode decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.
func URLEncode ¶
URLEncode returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. It is encoded the same way that the posted data from a WWW form is encoded, that is the same way as in application/x-www-form-urlencoded media type.
Types ¶
This section is empty.