helper

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocalIp = GetLocalIP()
View Source
var PortVal = "8998" //默认值,会被app.toml覆盖

Functions

func AssignLocalAddr

func AssignLocalAddr() (*net.TCPAddr, error)

func BytesToString

func BytesToString(b []byte) string

func CErr

func CErr(msg string) string

func CInfo

func CInfo(msg string) string

func CWarn

func CWarn(msg string) string

func Decode added in v1.3.5

func Decode(b []byte) []byte

Decode 将 \u1234 转为中文,将 \/ 转为 /。

func GetLocalIP

func GetLocalIP() string

func GetPidByName

func GetPidByName(binName string) (int, string)

GetPidByName 根据进程名字,读取进程id

func Json2SingleLayerMap

func Json2SingleLayerMap(body []byte) (map[string]json.RawMessage, error)

json解析成单层map, 打平多层嵌套,多层嵌套通过"."连接key 对于数组采用数字作为key

func MVFile

func MVFile(ori, des string) int

MVFile 重命名文件

func MkdirForce

func MkdirForce(dir string) int

MkdirForce 强制创建目录

func PathExists

func PathExists(path string) bool

PathExists 判断路径是否存在

func ReadFileBytes

func ReadFileBytes(confFile string) ([]byte, error)

ReadFile 读取并返回整个文件内容

func ReadLines

func ReadLines(confFile string) ([]string, error)

ReadLines 逐行读取并返回文件内容

func SetQuickAck

func SetQuickAck(conn *net.TCPConn) error

func StartDetached

func StartDetached(cmd string, args []string) error

func StringToBytes

func StringToBytes(s string) []byte

func StripcSlashes

func StripcSlashes(data []byte) []byte

func TempFileWithSuffix

func TempFileWithSuffix(dir, prefix, suffix string) (f *os.File, err error)

TempFile creates a new temporary file in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFile simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.

func UnescapeSlash

func UnescapeSlash(ori []byte) []byte

func WriteFile

func WriteFile(fpath string, content []byte) error

func WriteFileString

func WriteFileString(confFile, data string) error

WriteFileString 写入并覆盖配置文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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