camUtils

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var C = new(CUtil)
View Source
var Console = new(ConsoleUtil)
View Source
var Encrypt = new(EncryptUtil)
View Source
var Env = newEnvUtil()
View Source
var File = new(FileUtil)
View Source
var Json = new(JsonUtil)
View Source
var Migrate = new(MigrateUtil)
View Source
var Reflect = new(ReflectUtil)
View Source
var String = new(StringUtil)
View Source
var Time = new(TimeUtil)
View Source
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 (c *CUtil) Float32ToString(num float32) string

func (*CUtil) Float64ToString added in v0.4.0

func (c *CUtil) Float64ToString(num float64) string

func (*CUtil) Int16ToString added in v0.4.0

func (c *CUtil) Int16ToString(num int16) string

func (*CUtil) Int32ToString added in v0.4.0

func (c *CUtil) Int32ToString(num int32) string

func (*CUtil) Int64ToString added in v0.4.0

func (c *CUtil) Int64ToString(num int64) string

func (*CUtil) Int8ToString added in v0.4.0

func (c *CUtil) Int8ToString(num int8) string

func (*CUtil) IntToString added in v0.4.0

func (c *CUtil) IntToString(num int) string

func (*CUtil) InterfaceToString added in v0.5.0

func (c *CUtil) InterfaceToString(v interface{}) string

func (*CUtil) StringToFloat32 added in v0.4.0

func (c *CUtil) StringToFloat32(str string) float32

func (*CUtil) StringToFloat64 added in v0.4.0

func (c *CUtil) StringToFloat64(str string) float64

func (*CUtil) StringToInt added in v0.4.0

func (c *CUtil) StringToInt(str string) int

func (*CUtil) StringToInt16 added in v0.5.0

func (c *CUtil) StringToInt16(str string) int16

func (*CUtil) StringToInt32 added in v0.5.0

func (c *CUtil) StringToInt32(str string) int32

func (*CUtil) StringToInt64 added in v0.4.0

func (c *CUtil) StringToInt64(str string) int64

func (*CUtil) StringToInt8 added in v0.5.0

func (c *CUtil) StringToInt8(str string) int8

func (*CUtil) StringToUint added in v0.4.0

func (c *CUtil) StringToUint(str string) uint

func (*CUtil) StringToUint16 added in v0.5.0

func (c *CUtil) StringToUint16(str string) uint16

func (*CUtil) StringToUint32 added in v0.5.0

func (c *CUtil) StringToUint32(str string) uint32

func (*CUtil) StringToUint64 added in v0.4.0

func (c *CUtil) StringToUint64(str string) uint64

func (*CUtil) StringToUint8 added in v0.5.0

func (c *CUtil) StringToUint8(str string) uint8

func (*CUtil) Uint16ToString added in v0.4.0

func (c *CUtil) Uint16ToString(num uint16) string

func (*CUtil) Uint32ToString added in v0.4.0

func (c *CUtil) Uint32ToString(num uint32) string

func (*CUtil) Uint64ToString added in v0.4.0

func (c *CUtil) Uint64ToString(num uint64) string

func (*CUtil) Uint8ToString added in v0.4.0

func (c *CUtil) Uint8ToString(num uint8) string

func (*CUtil) UintToString added in v0.4.0

func (c *CUtil) UintToString(num uint) string

func (*CUtil) Version added in v0.5.0

func (c *CUtil) Version() string

Framework version

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) IsPressY

func (util *ConsoleUtil) IsPressY() bool

check user whether press y

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 EnvUtil

type EnvUtil struct {
	// contains filtered or unexported fields
}

func (*EnvUtil) Get

func (util *EnvUtil) Get(key string) string

type FileUtil

type FileUtil struct {
}

file util

func (*FileUtil) AppendFile

func (util *FileUtil) AppendFile(filename string, content []byte) error

append content end of the file

func (*FileUtil) Dir

func (util *FileUtil) Dir(path string) string

get parent dir path: absolute filename or absolute directory

func (*FileUtil) Exists

func (util *FileUtil) Exists(path string) bool

check whether file exists

func (*FileUtil) GetRunPath

func (util *FileUtil) GetRunPath() string

Get the path where the program is running

func (*FileUtil) IsDir

func (util *FileUtil) IsDir(path string) bool

check path whether dir

func (*FileUtil) Mkdir

func (util *FileUtil) Mkdir(path string) error

make dir create dir

func (*FileUtil) ReadFile

func (util *FileUtil) ReadFile(filePath string) ([]byte, error)

read all content from file

func (*FileUtil) Remove

func (util *FileUtil) Remove(filename string) error

delete file

func (*FileUtil) RemoveAll

func (util *FileUtil) RemoveAll(path string) error

remove all of file inside the path

func (*FileUtil) Rename

func (util *FileUtil) Rename(oldPath, newPath string) error

rename file or dir

func (*FileUtil) ScanDir

func (util *FileUtil) ScanDir(dir string, withDir bool) ([]os.FileInfo, error)

View all files in the folder dir: absolute path withDir: Whether the returned result contains folders

func (*FileUtil) Size

func (util *FileUtil) Size(filename string) int64

get file size in bytes. only support file

func (*FileUtil) Stat

func (util *FileUtil) Stat(path string) (os.FileInfo, error)

get fileInfo

func (*FileUtil) WriteFile

func (util *FileUtil) WriteFile(filename string, content []byte) error

write all content to file

type JsonUtil

type JsonUtil struct {
}

func (*JsonUtil) DecodeToObj

func (util *JsonUtil) DecodeToObj(bytes []byte, obj interface{})

decode to struct

func (*JsonUtil) Encode

func (util *JsonUtil) Encode(v interface{}) []byte

encode to bytes

func (*JsonUtil) EncodeBeautiful

func (util *JsonUtil) EncodeBeautiful(v interface{}) []byte

encode to bytes and beautify json

func (*JsonUtil) EncodeStr

func (util *JsonUtil) EncodeStr(v interface{}) string

encode to string

func (*JsonUtil) EncodeStrBeautiful

func (util *JsonUtil) EncodeStrBeautiful(v interface{}) string

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) Random

func (util *StringUtil) Random(size int) string

get random 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) UUID

func (util *StringUtil) UUID() string

generate UUID

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) NowDate

func (util *TimeUtil) NowDate() string

get now date. Example: 2006-01-02

func (*TimeUtil) NowDateTime

func (util *TimeUtil) NowDateTime() string

get now datetime. Example: 2006-01-02 15:04:05

type UrlUtil

type UrlUtil struct {
}

utl util

func (*UrlUtil) HumpToUrl

func (util *UrlUtil) HumpToUrl(hump string) string

Hump to url. Example: GetUserList => get-user-list

func (*UrlUtil) SplitUrl

func (util *UrlUtil) SplitUrl(url string) []string

split url Example: /test/test/abc/222?name=aa&age=cc split to: ["test", "test", "abc", "222"]

func (*UrlUtil) UrlToHump

func (util *UrlUtil) UrlToHump(url string) string

url to Hump. Example: get-user-list => GetUserList

Jump to

Keyboard shortcuts

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