util

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2020 License: Apache-2.0 Imports: 20 Imported by: 299

Documentation

Index

Constants

View Source
const (
	// Spider中启用Keyin的初始值
	USE_KEYIN = "\r\t\n"
)

Variables

This section is empty.

Functions

func Atoa

func Atoa(str interface{}) string

func Atoi

func Atoi(str interface{}) int

func Atoui

func Atoui(str interface{}) uint

func Bytes2String

func Bytes2String(b []byte) string

Bytes2String直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变。 效率是string([]byte{})的百倍以上,且转换量越大效率优势越明显。

func CheckErr

func CheckErr(err error)

检查并打印错误

func CheckErrPanic

func CheckErrPanic(err error)

func ExcelSheetNameReplace

func ExcelSheetNameReplace(fileName string) string

将Excel工作表名中非法字符替换为下划线

func FileNameReplace

func FileNameReplace(fileName string) string

func GetWDPath

func GetWDPath() string

The GetWDPath gets the work directory path.

func HashString

func HashString(encode string) uint64

func IsDirExists

func IsDirExists(path string) bool

The IsDirExists judges path is directory or not.

func IsFileExists

func IsFileExists(path string) bool

The IsFileExists judges path is file or not.

func IsNum

func IsNum(a string) bool

The IsNum judges string is number or not.

func JsonString

func JsonString(obj interface{}) string

将对象转为json字符串

func JsonpToJson

func JsonpToJson(json string) string

JsonpToJson modify jsonp string to json string Example: forbar({a:"1",b:2}) to {"a":"1","b":2}

func KeyinsParse

func KeyinsParse(keyins string) []string

切分用户输入的自定义信息

func MakeHash

func MakeHash(s string) string

string to hash

func MakeMd5

func MakeMd5(obj interface{}, length int) string

制作特征值方法二

func MakeUnique

func MakeUnique(obj interface{}) string

制作特征值方法一

func Mkdir

func Mkdir(Path string)

创建目录

func RandomCreateBytes

func RandomCreateBytes(n int, alphabets ...byte) []byte

RandomCreateBytes generate random []byte by specify chars.

func RelPath

func RelPath(targpath string) string

转相对路径

func String2Bytes

func String2Bytes(s string) []byte

String2Bytes直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变。 效率是string([]byte{})的百倍以上,且转换量越大效率优势越明显。 转换之后若没做其他操作直接改变里面的字符,则程序会崩溃。 如 b:=String2bytes("xxx"); b[1]='d'; 程序将panic。

func WalkDir

func WalkDir(targpath string, suffixes ...string) (dirlist []string)

遍历目录,可指定后缀

func WalkFiles

func WalkFiles(targpath string, suffixes ...string) (filelist []string)

遍历文件,可指定后缀

func WalkRelDir

func WalkRelDir(targpath string, suffixes ...string) (dirlist []string)

遍历目录,可指定后缀,返回相对路径

func WalkRelFiles

func WalkRelFiles(targpath string, suffixes ...string) (filelist []string)

遍历文件,可指定后缀,返回相对路径

func XML2mapstr

func XML2mapstr(xmldoc string) map[string]string

simple xml to string support utf8

Types

This section is empty.

Jump to

Keyboard shortcuts

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