Documentation ¶
Index ¶
- Constants
- func CheckError(err error)
- func CheckFatal(err error)
- func ConfigRuntime()
- func DeepCopy(dst, src interface{}) error
- func EncryptMAC(s, key string) []byte
- func EncryptMD5(s string) []byte
- func ExecCommand(commandName string, arg ...string) ([]string, error)
- func InitConfig(appName, cfgFile string)
- func JSONObjectConvert(obj1 interface{}, obj2 interface{}) error
- func PrettyJSON(b []byte) ([]byte, error)
- func PrettyObject(obj interface{}) []byte
- func RandInt64(min, max int64) int64
- func RandString(length int) []byte
- func ReadConfigFromKey(configKey string, config interface{})
- func ReadEnv(obj interface{}) error
- func ReadFileData(path string) ([]byte, error)
- func ReadJSON(obj interface{}, data []byte) error
- type Error
- type Timer
Constants ¶
View Source
const ( //ErrCodedParams 请求参数错误 ErrCodedParams = 400 //ErrCodeNotFound 没有发现 ErrCodeNotFound = 404 //ErrCodeInternal 内部错误 ErrCodeInternal = 500 )
Variables ¶
This section is empty.
Functions ¶
func EncryptMAC ¶
EncryptMAC 用hmac加密字符串。每次加密后的密文长度都是32位。可用于字符串完整性校验
func ExecCommand ¶
ExecCommand 执行系统命令
func InitConfig ¶
func InitConfig(appName, cfgFile string)
InitConfig 读取配置文件,如果有配置文件(cfgFile != ""),读取配置文件。 否则,在/etc/[appName]/、$HOME/.[appName]/、./config/目录下需找文件名为config的配置文件。
func JSONObjectConvert ¶
func JSONObjectConvert(obj1 interface{}, obj2 interface{}) error
JSONObjectConvert 将一个对象转换成序列化后的另一个对象
func PrettyObject ¶
func PrettyObject(obj interface{}) []byte
func ReadConfigFromKey ¶
func ReadConfigFromKey(configKey string, config interface{})
ReadConfigFromKey 从读取的配置中寻找符合configKey的配置,并赋值到配置对象(config)定义的变量中。 如果config有环境变量定义,那么以环境变量设置为准
func ReadFileData ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.