Documentation ¶
Index ¶
- Variables
- type CUtil
- func (c *CUtil) Float32ToString(num float32) string
- func (c *CUtil) Float64ToString(num float64) string
- func (c *CUtil) Int16ToString(num int16) string
- func (c *CUtil) Int32ToString(num int32) string
- func (c *CUtil) Int64ToString(num int64) string
- func (c *CUtil) Int8ToString(num int8) string
- func (c *CUtil) IntToString(num int) string
- func (c *CUtil) InterfaceToString(v interface{}) string
- func (c *CUtil) StringToFloat32(str string) float32
- func (c *CUtil) StringToFloat64(str string) float64
- func (c *CUtil) StringToInt(str string) int
- func (c *CUtil) StringToInt16(str string) int16
- func (c *CUtil) StringToInt32(str string) int32
- func (c *CUtil) StringToInt64(str string) int64
- func (c *CUtil) StringToInt8(str string) int8
- func (c *CUtil) StringToUint(str string) uint
- func (c *CUtil) StringToUint16(str string) uint16
- func (c *CUtil) StringToUint32(str string) uint32
- func (c *CUtil) StringToUint64(str string) uint64
- func (c *CUtil) StringToUint8(str string) uint8
- func (c *CUtil) Uint16ToString(num uint16) string
- func (c *CUtil) Uint32ToString(num uint32) string
- func (c *CUtil) Uint64ToString(num uint64) string
- func (c *CUtil) Uint8ToString(num uint8) string
- func (c *CUtil) UintToString(num uint) string
- func (c *CUtil) Version() string
- type ConsoleUtil
- func (util *ConsoleUtil) HasCommand(cmd string) bool
- func (util *ConsoleUtil) IsLinux() bool
- func (util *ConsoleUtil) IsPressY() bool
- func (util *ConsoleUtil) IsRunByCommand() bool
- func (util *ConsoleUtil) IsWindows() bool
- func (util *ConsoleUtil) Run(cmd string) ([]byte, error)
- func (util *ConsoleUtil) RunNoOutput(cmd string) error
- func (util *ConsoleUtil) Start(cmd string) error
- type EncryptUtil
- type EnvUtil
- type FileUtil
- func (util *FileUtil) AppendFile(filename string, content []byte) error
- func (util *FileUtil) Dir(path string) string
- func (util *FileUtil) Exists(path string) bool
- func (util *FileUtil) GetRunPath() string
- func (util *FileUtil) IsDir(path string) bool
- func (util *FileUtil) Mkdir(path string) error
- func (util *FileUtil) ReadFile(filePath string) ([]byte, error)
- func (util *FileUtil) Remove(filename string) error
- func (util *FileUtil) RemoveAll(path string) error
- func (util *FileUtil) Rename(oldPath, newPath string) error
- func (util *FileUtil) ScanDir(dir string, withDir bool) ([]os.FileInfo, error)
- func (util *FileUtil) Size(filename string) int64
- func (util *FileUtil) Stat(path string) (os.FileInfo, error)
- func (util *FileUtil) WriteFile(filename string, content []byte) error
- type JsonUtil
- type MigrateUtil
- type ReflectUtil
- type StringUtil
- func (util *StringUtil) FillZero(num string, digit int) string
- func (util *StringUtil) Float64ToString(num float64) string
- func (util *StringUtil) HumpToUnder(hump string) string
- func (util *StringUtil) Int64ToString(num int64) string
- func (util *StringUtil) Random(size int) string
- func (util *StringUtil) StringToFloat64(str string) float64
- func (util *StringUtil) StringToInt64(str string) int64
- func (util *StringUtil) StringToUint64(str string) uint64
- func (util *StringUtil) UUID() string
- func (util *StringUtil) Uint64ToString(num uint64) string
- func (util *StringUtil) UnderToHump(url string) string
- type TimeUtil
- type UrlUtil
Constants ¶
This section is empty.
Variables ¶
var C = new(CUtil)
var Console = new(ConsoleUtil)
var Encrypt = new(EncryptUtil)
var Env = newEnvUtil()
var File = new(FileUtil)
var Json = new(JsonUtil)
var Migrate = new(MigrateUtil)
var Reflect = new(ReflectUtil)
var String = new(StringUtil)
var Time = new(TimeUtil)
var Url = new(UrlUtil)
Functions ¶
This section is empty.
Types ¶
type CUtil ¶ added in v0.4.0
type CUtil struct { }
Common utils
func (*CUtil) Float32ToString ¶ added in v0.5.0
func (*CUtil) Float64ToString ¶ added in v0.4.0
func (*CUtil) Int16ToString ¶ added in v0.4.0
func (*CUtil) Int32ToString ¶ added in v0.4.0
func (*CUtil) Int64ToString ¶ added in v0.4.0
func (*CUtil) Int8ToString ¶ added in v0.4.0
func (*CUtil) IntToString ¶ added in v0.4.0
func (*CUtil) InterfaceToString ¶ added in v0.5.0
func (*CUtil) StringToFloat32 ¶ added in v0.4.0
func (*CUtil) StringToFloat64 ¶ added in v0.4.0
func (*CUtil) StringToInt ¶ added in v0.4.0
func (*CUtil) StringToInt16 ¶ added in v0.5.0
func (*CUtil) StringToInt32 ¶ added in v0.5.0
func (*CUtil) StringToInt64 ¶ added in v0.4.0
func (*CUtil) StringToInt8 ¶ added in v0.5.0
func (*CUtil) StringToUint ¶ added in v0.4.0
func (*CUtil) StringToUint16 ¶ added in v0.5.0
func (*CUtil) StringToUint32 ¶ added in v0.5.0
func (*CUtil) StringToUint64 ¶ added in v0.4.0
func (*CUtil) StringToUint8 ¶ added in v0.5.0
func (*CUtil) Uint16ToString ¶ added in v0.4.0
func (*CUtil) Uint32ToString ¶ added in v0.4.0
func (*CUtil) Uint64ToString ¶ added in v0.4.0
func (*CUtil) Uint8ToString ¶ added in v0.4.0
func (*CUtil) UintToString ¶ added in v0.4.0
type ConsoleUtil ¶
type ConsoleUtil struct { }
func (*ConsoleUtil) HasCommand ¶ added in v0.4.3
func (util *ConsoleUtil) HasCommand(cmd string) bool
Check whether the system has the command
func (*ConsoleUtil) IsLinux ¶
func (util *ConsoleUtil) IsLinux() bool
func (*ConsoleUtil) IsRunByCommand ¶
func (util *ConsoleUtil) IsRunByCommand() bool
check is run by command mode.
func (*ConsoleUtil) IsWindows ¶
func (util *ConsoleUtil) IsWindows() bool
func (*ConsoleUtil) Run ¶
func (util *ConsoleUtil) Run(cmd string) ([]byte, error)
runs the command and returns its combined standard output and standard error.
func (*ConsoleUtil) RunNoOutput ¶ added in v0.4.3
func (util *ConsoleUtil) RunNoOutput(cmd string) error
Run and no output to console
func (*ConsoleUtil) Start ¶
func (util *ConsoleUtil) Start(cmd string) error
runs the command and returns its combined standard, and print output content realtime output and standard error.
type EncryptUtil ¶
type EncryptUtil struct { }
func (*EncryptUtil) Md5 ¶
func (util *EncryptUtil) Md5(data []byte) string
type FileUtil ¶
type FileUtil struct { }
file util
func (*FileUtil) AppendFile ¶
append content end of the file
func (*FileUtil) GetRunPath ¶
Get the path where the program is running
func (*FileUtil) ScanDir ¶
View all files in the folder dir: absolute path withDir: Whether the returned result contains folders
type JsonUtil ¶
type JsonUtil struct { }
func (*JsonUtil) DecodeToObj ¶
decode to struct
func (*JsonUtil) EncodeBeautiful ¶
encode to bytes and beautify json
func (*JsonUtil) EncodeStrBeautiful ¶
encode to string and beautify json
type MigrateUtil ¶
type MigrateUtil struct { }
migrate util
func (*MigrateUtil) IdByDatetime ¶
func (util *MigrateUtil) IdByDatetime() string
generate migration's file id by datetime using system timezone
func (*MigrateUtil) IdByTimestamp ¶
func (util *MigrateUtil) IdByTimestamp() string
generate migration's file id by timestamp
type ReflectUtil ¶
type ReflectUtil struct { }
reflect tool
func (*ReflectUtil) GetStructName ¶
func (util *ReflectUtil) GetStructName(i interface{}) string
get struct name
func (*ReflectUtil) ValueOfElem ¶
func (util *ReflectUtil) ValueOfElem(i interface{}) reflect.Value
reflect to element. If reflect value is point, change it to element
type StringUtil ¶
type StringUtil struct { }
string util
func (*StringUtil) FillZero ¶
func (util *StringUtil) FillZero(num string, digit int) string
Fill the number with 0 example:
FillZero("12", 2) => "12" FillZero("9", 2) => "09" FillZero("129", 2) => "129"
func (*StringUtil) Float64ToString ¶ added in v0.4.0
func (util *StringUtil) Float64ToString(num float64) string
float64 to string
func (*StringUtil) HumpToUnder ¶
func (util *StringUtil) HumpToUnder(hump string) string
hump to underline example: GetUserList => get_user_list
func (*StringUtil) Int64ToString ¶ added in v0.4.0
func (util *StringUtil) Int64ToString(num int64) string
int64 to string
func (*StringUtil) StringToFloat64 ¶ added in v0.4.0
func (util *StringUtil) StringToFloat64(str string) float64
string to float64
func (*StringUtil) StringToInt64 ¶ added in v0.4.0
func (util *StringUtil) StringToInt64(str string) int64
string to int64
func (*StringUtil) StringToUint64 ¶ added in v0.4.0
func (util *StringUtil) StringToUint64(str string) uint64
string to uint64
func (*StringUtil) Uint64ToString ¶ added in v0.4.0
func (util *StringUtil) Uint64ToString(num uint64) string
uint64 to string
func (*StringUtil) UnderToHump ¶
func (util *StringUtil) UnderToHump(url string) string
underline to hump example: get_user_list => GetUserList
type TimeUtil ¶
type TimeUtil struct { }
func (*TimeUtil) NowDateTime ¶
get now datetime. Example: 2006-01-02 15:04:05