代码拉取完成,页面将自动刷新
package mego
import (
"log"
"os"
"path"
"path/filepath"
"strings"
"unsafe"
)
// Bytes2Str convert the byte array to string quickly
func Bytes2Str(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
// Str2Bytes convert the string to byte array quickly
func Str2Bytes(s string) []byte {
x := (*[2]uintptr)(unsafe.Pointer(&s))
h := [3]uintptr{x[0], x[1], x[1]}
return *(*[]byte)(unsafe.Pointer(&h))
}
// StrJoin combine some strings to a single string
func StrJoin(arr ...string) string {
if len(arr) == 0 {
return ""
}
return strings.Join(arr, "")
}
// ClearFilePath clear the pathStr and return the shortest path.
func ClearFilePath(pathStr string) string {
return path.Clean(strings.Replace(pathStr, "\\", "/", -1))
}
// GetExeDir get the current directory that the executable file is located in.
func GetExeDir() string {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
return dir
}
// GetWD get the current working directory
func GetWD() string {
str, err := os.Getwd()
panicErr(err)
return str
}
func isA2Z(c byte) bool {
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')
}
func isNumber(c byte) bool {
return c >= '0' && c <= '9'
}
func ensurePostFix(str, postFix string) string {
if strings.HasSuffix(str, postFix) {
return str
}
return StrJoin(str, postFix)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。