util

package
v0.0.0-...-6ac6f58 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckExecutable

func CheckExecutable(target string) (string, error)

CheckExecutable check executable is exist

func CheckExecutableWithPath

func CheckExecutableWithPath(target, path, pathExt string) (string, error)

CheckExecutableWithPath check executable is exist if path is set, then will look from it, if path is empty, then will look from env PATH pathExt define the PATHEXT in windows

func CheckFileWithCallerPath

func CheckFileWithCallerPath(target string) (string, error)

try search file in caller path

func Environ

func Environ() map[string]string

Environ return the current environment variables in map

func GetCaller

func GetCaller() string

GetCaller return the current caller functions

func GetExcPath

func GetExcPath() string

GetExcPath get current Exec caller and return the dir

func GetGlobalDir

func GetGlobalDir() string

GetGlobalDir

func GetHomeDir

func GetHomeDir() string

GetHomeDir get home dir by system env

func GetIPAddress

func GetIPAddress() (addrList []string)

GetIPAddress get local usable inner ip address

func GetLogsDir

func GetLogsDir() string

GetLogsDir get the runtime log dir

func GetPumpCacheDir

func GetPumpCacheDir() string

GetPumpCacheDir get the runtime pump cache dir

func GetRecordDir

func GetRecordDir() string

GetRecordDir get the record dir

func GetRuntimeDir

func GetRuntimeDir() string

GetRuntimeDir get the runtime tmp dir

func IsLocalIP

func IsLocalIP(ip net.IP) bool

IsLocalIP check whether ip is local

func ListProcess

func ListProcess(target string) ([]*process.Process, error)

ListProcess list process by process name

func LookPath

func LookPath(target, path, _ string) (string, error)

LookPath get the executable target in PATH

func Lz4Compress

func Lz4Compress(src []byte) ([]byte, error)

Lz4Compress to implement lz4 compress

func Lz4Uncompress

func Lz4Uncompress(src []byte, dst []byte) ([]byte, error)

Lz4Uncompress to implement lz4 uncompress

func Now

func Now(t *time.Time)

Now get the current time

func ProcessExist

func ProcessExist(target string) bool

ProcessExist check if target process exsit

func ProcessExistTimeoutAndKill

func ProcessExistTimeoutAndKill(target string, timeout time.Duration) bool

ProcessExistTimeoutAndKill check target process with name, and kill it after timeout

func QuoteSpacePath

func QuoteSpacePath(s string) string

QuoteSpacePath quote path if include space

func SearchProjectID

func SearchProjectID() string

SearchProjectID try get project id

func UniqID

func UniqID() string

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

Utf8ToGbk transfer utf-8 to gbk

Types

type PrintLevel

type PrintLevel int32

PrintLevel define log level

const (
	PrintFatal PrintLevel = iota
	PrintError
	PrintWarn
	PrintInfo
	PrintDebug
	PrintNothing
)

define log levels

func (PrintLevel) String

func (p PrintLevel) String() string

String return the string of PrintLevel

type ProjectSetting

type ProjectSetting struct {
	ProjectID string `json:"project_id"`
}

ProjectSetting describe the project setting

Jump to

Keyboard shortcuts

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