Documentation
¶
Overview ¶
Package utils 一些常用的函数集合。
Index ¶
- func CurrentDir() string
- func CurrentFile() string
- func CurrentFunction() string
- func CurrentLine() int
- func CurrentPath(path string) string
- func DumpGoFile(path, content string) errordeprecated
- func DumpGoSource(path string, content []byte) error
- func FileExists(path string) bool
- func GetSystemLanguageTag() (language.Tag, error)
- func HasDuplication(slice interface{}, eq func(i, j int) bool) int
- func MD5(str string) string
- func Merge(deep bool, elems ...interface{}) error
- func Round(v float64) int64
- func SplitPath(path string) []string
- func TraceStack(level int, msg ...interface{}) (string, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentFile ¶ added in v1.2.0
func CurrentFile() string
CurrentFile 获取`调用者`所在的文件
相当于部分语言的 __FILE__
func CurrentFunction ¶ added in v1.2.0
func CurrentFunction() string
CurrentFunction 获取`调用者`所在的函数名
相当于部分语言的 __FUNCTION__
func DumpGoFile
deprecated
added in
v1.1.0
func GetSystemLanguageTag ¶ added in v1.3.0
GetSystemLanguageTag 返回当前系统的本地化信息
*nix 系统会使用 LANG 环境变量中的值,windows 在 LANG 环境变量不存在的情况下,调用 GetUserDefaultLocaleName 函数获取。
func HasDuplication ¶ added in v1.4.0
HasDuplication 检测数组中是否包含重复的值
Example ¶
intSlice := []int{1, 2, 3, 7, 0, 4, 7}
fmt.Println(HasDuplication(intSlice, func(i, j int) bool {
return intSlice[i] == intSlice[j]
}))
Output: 6
func TraceStack ¶
TraceStack 返回调用者的堆栈信息
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.