utils

package
v5.0.3-release+incompa... Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = errors.New("Record not found.")
	ErrValueMayChanged = errors.New("The value has been changed by others on this time.")

	ErrEmptyJobName        = errors.New("Name of job is empty.")
	ErrEmptyJobCommand     = errors.New("Command of job is empty.")
	ErrIllegalJobId        = errors.New("Invalid id that includes illegal characters such as '/'.")
	ErrIllegalJobGroupName = errors.New("Invalid job group name that includes illegal characters such as '/'.")

	ErrEmptyNodeGroupName = errors.New("Name of node group is empty.")
	ErrIllegalNodeGroupId = errors.New("Invalid node group id that includes illegal characters such as '/'.")

	ErrSecurityInvalidCmd  = errors.New("Security error: the suffix of script file is not on the whitelist.")
	ErrSecurityInvalidUser = errors.New("Security error: the user is not on the whitelist.")
	ErrNilRule             = errors.New("invalid job rule, empty timer.")
)

Functions

func LoadExtendConf

func LoadExtendConf(filePath string, v interface{}) error

加载json(可配置扩展字段)配置文件

func LocalIP

func LocalIP() (net.IP, error)

LocalIP 获取本机 ip 获取第一个非 loopback ip

func LocalMacAddr

func LocalMacAddr() (string, error)

LocalMacAddr 获取本机Mac地址

func RandString

func RandString(length int, characters ...byte) string

func SetExtendTag

func SetExtendTag(tag string)

设置扩展标识,如果不设置,默认为 '@extend:'

func SetPathTag

func SetPathTag(tag string)

设置当前路径标识,如果不设置,默认为 '@pwd@' @pwd@ 会被替换成当前文件的路径, 至于是绝对路径还是相对路径,取决于读取文件时,传入的是绝对路径还是相对路径

func SetRoot

func SetRoot(r string)

Types

type APIHandleError

type APIHandleError struct {
	Code int
	Err  error
}

APIHandleError handle create err for api

func CreateAPIHandleError

func CreateAPIHandleError(code int, err error) *APIHandleError

CreateAPIHandleError create APIHandleError

func CreateAPIHandleErrorFromDBError

func CreateAPIHandleErrorFromDBError(msg string, err error) *APIHandleError

CreateAPIHandleErrorFromDBError from db error create APIHandleError

func (*APIHandleError) Error

func (a *APIHandleError) Error() string

func (*APIHandleError) Handle

func (a *APIHandleError) Handle(r *http.Request, w http.ResponseWriter)

Handle 处理

func (*APIHandleError) String

func (a *APIHandleError) String() string

Jump to

Keyboard shortcuts

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