Documentation ¶
Index ¶
- Constants
- Variables
- func AppendToFile(file *os.File, appendContent string)
- func Base64ToFile(fileData string) (*os.File, error)
- func ChangeWorkPath(wp string)
- func ConvertPNG2JPG(pngFileName string, jpgFileName string) error
- func ConvertToFloat32(number string) float32
- func ConvertToFloat64(number string) float64
- func ConvertToInt(number string) int
- func ConvertToInt32(number string) int32
- func ConvertToInt64(number string) int64
- func ConvertToUint(number string) uint
- func CopyFile(src string, dst string) error
- func DirectoryExists(path string) (exists bool, err error)
- func DumpBytes(fileName string, data []byte) error
- func DumpFormToFile(file *multipart.FileHeader, fullPath string, fileName string) (string, error)
- func DumpInterface(fileName string, data interface{}) error
- func DumpString(fileName string, data string) error
- func ExecBash(c string) error
- func ExecCmd(timeout time.Duration, name string, arg ...string) (string, error)
- func ExecCommand(timeout time.Duration, name string, arg ...string) ([]string, error)
- func FileExists(path string) (exists bool, err error)
- func FileMD5(filePath string) (string, error)
- func FileSize(path string) (size int64, err error)
- func FileWithExt(fileName string, ext string) bool
- func FormatHumanDisplayTime(time int64) string
- func FormatHumanTime(time int64) string
- func FormatMessage(template string, args ...interface{}) string
- func FormatTime(time int64) string
- func GenSignature(params url.Values, secretKey string) string
- func GetCallerFrame(skip int) (frame runtime.Frame, ok bool)
- func GetCurrentServerIp(serverAddress string) string
- func GetExeDir() string
- func GetHostName() string
- func GetImgBase64(path string) (baseImg string, err error)
- func GetLocalImageBase64(path string) (string, error)
- func GetNextId() int64
- func GetTaskSubFolder(rootPath string, taskId int64) string
- func GetTempFileName(pattern string) (string, error)
- func GetUrlImgBase64(path string) (baseImg string, err error)
- func GoId() int64
- func HttpAddParam(address string, k string, v string) (string, error)
- func HttpPost(url string, content string, timeout time.Duration) error
- func HttpRequest(url string, post bool, content []byte, contentType string, ...) ([]byte, error)
- func Int64Abs(n int64) int64
- func Int64Max(x, y int64) int64
- func Int64Min(x, y int64) int64
- func IsLocalHost(addr string) bool
- func IsNumeric(number string) bool
- func ListFSCmd(fs string) (map[string]string, error)
- func ListFiles(folderName string, end string) ([]string, error)
- func ListImageFiles(folderName string) ([]string, error)
- func MountCmd(c string) error
- func NetworkStream(name string) bool
- func NewRat(val float64, iterations int64, stepPrecision float64) *big.Rat
- func NewRatI(val float64, iterations int64) *big.Rat
- func NewRatP(val float64, stepPrecision float64) *big.Rat
- func Parse(fileName string, outFileName string, mapInfo map[string]interface{}) error
- func ParseJsonArray(a []interface{}, f func(k string, v interface{}))
- func ParseJsonMap(m map[string]interface{}, f func(k string, v interface{}))
- func ParseTranscoderProgress(s string, prefix string) (int32, float32, bool)
- func PathExists(path string) (exists bool, err error)
- func PrintMemUsage()
- func RSABase64Decrypt(encodedData string, publicKey string) (string, error)
- func RSABase64Encrypt(data []byte, publicKey string) (string, error)
- func ReadFileToByte(fileName string) []byte
- func ReadFileToString(fileName string) string
- func RsaPublicDecrypt(pubKey *rsa.PublicKey, data []byte) []byte
- func RunBash(c string) (string, error)
- func SFormatMessage(template string, fmtArgs []interface{}) string
- func SplitMultiLineString(is string, removeEmpty bool) []string
- func SplitString(s string, sep string) []string
- func ToJpeg(imageBytes []byte) ([]byte, error)
- func ToPrintString(v interface{}) string
- func ToString(v interface{}) string
- func TruncateString(str string, length int, unicodeMode bool) string
- func UnmountCmd(c string) error
- func UrlToFile(fullURLFile string, fullName string, fileExt string) (*os.File, error)
- func WriteBase64ToFileName(base64Data string, targetFileName string) error
- func WriteJsonToFile(fileName string, v interface{}) error
- func XmlEscape(s string) string
- type ID
- func ParseBase2(id string) (ID, error)
- func ParseBase32(b []byte) (ID, error)
- func ParseBase36(id string) (ID, error)
- func ParseBase58(b []byte) (ID, error)
- func ParseBase64(id string) (ID, error)
- func ParseBytes(id []byte) (ID, error)
- func ParseInt64(id int64) ID
- func ParseIntBytes(id [8]byte) ID
- func ParseString(id string) (ID, error)
- func (f ID) Base2() string
- func (f ID) Base32() string
- func (f ID) Base36() string
- func (f ID) Base58() string
- func (f ID) Base64() string
- func (f ID) Bytes() []byte
- func (f ID) Int64() int64
- func (f ID) IntBytes() [8]byte
- func (f ID) MarshalJSON() ([]byte, error)
- func (f ID) Node() int64
- func (f ID) Step() int64
- func (f ID) String() string
- func (f ID) Time() int64
- func (f *ID) UnmarshalJSON(b []byte) error
- type JSONSyntaxError
- type Job
- type Node
- type Pool
- func (p *Pool) Add(t Job)
- func (p *Pool) Close()
- func (p *Pool) Exist(t Job) bool
- func (p *Pool) ExistPending(t Job) bool
- func (p *Pool) Remove(t Job) bool
- func (p *Pool) Run()
- func (p *Pool) RunningTasks() int32
- func (p *Pool) SetMaxWorkerNumber(maxWorkerNum int32)
- func (p *Pool) WaitAllDone()
- func (p *Pool) WaitingTasks() int32
- type Process
- type Task
Constants ¶
const MaxIterations = 5000
Variables ¶
var ( // Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds // You may customize this to set a different epoch for your application. Epoch int64 = 1498612200000 // NodeBits holds the number of bits to use for Node // Remember, you have a total 14 bits to share between Node/Step NodeBits uint8 = 6 // StepBits holds the number of bits to use for Step // Remember, you have a total 14 bits to share between Node/Step StepBits uint8 = 8 )
var ErrInvalidBase32 = errors.New("invalid base32")
ErrInvalidBase32 is returned by ParseBase32 when given an invalid []byte
var ErrInvalidBase58 = errors.New("invalid base58")
ErrInvalidBase58 is returned by ParseBase58 when given an invalid []byte
Functions ¶
func AppendToFile ¶
func ChangeWorkPath ¶
func ChangeWorkPath(wp string)
func ConvertPNG2JPG ¶
func ConvertToFloat32 ¶
func ConvertToFloat64 ¶
func ConvertToInt ¶
func ConvertToInt32 ¶
func ConvertToInt64 ¶
func ConvertToUint ¶
func DirectoryExists ¶
func DumpFormToFile ¶
func DumpInterface ¶
func DumpString ¶
func ExecCommand ¶
func FileExists ¶
func FileWithExt ¶
func FormatHumanDisplayTime ¶
func FormatHumanTime ¶
func FormatMessage ¶
func FormatTime ¶
func GetCurrentServerIp ¶
func GetHostName ¶
func GetHostName() string
func GetImgBase64 ¶
func GetLocalImageBase64 ¶
func GetTaskSubFolder ¶
func GetTempFileName ¶
func GetUrlImgBase64 ¶
func HttpRequest ¶
func IsLocalHost ¶
func ListImageFiles ¶
func NetworkStream ¶
func ParseJsonArray ¶
func ParseJsonArray(a []interface{}, f func(k string, v interface{}))
func ParseJsonMap ¶
func ParseTranscoderProgress ¶
func PathExists ¶
func PrintMemUsage ¶
func PrintMemUsage()
func ReadFileToByte ¶
func ReadFileToString ¶
func SFormatMessage ¶
func SplitMultiLineString ¶
func SplitString ¶
func ToPrintString ¶
func ToPrintString(v interface{}) string
func UnmountCmd ¶
func WriteBase64ToFileName ¶
func WriteJsonToFile ¶
Types ¶
type ID ¶
type ID int64
An ID is a custom type used for a snowflake ID. This is used so we can attach methods onto the ID.
func ParseBase2 ¶
ParseBase2 converts a Base2 string into a snowflake ID
func ParseBase32 ¶
ParseBase32 parses a base32 []byte into a snowflake ID NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func ParseBase36 ¶
ParseBase36 converts a Base36 string into a snowflake ID
func ParseBase58 ¶
ParseBase58 parses a base58 []byte into a snowflake ID
func ParseBase64 ¶
ParseBase64 converts a base64 string into a snowflake ID
func ParseBytes ¶
ParseBytes converts a byte slice into a snowflake ID
func ParseIntBytes ¶
ParseIntBytes converts an array of bytes encoded as big endian integer as a snowflake ID
func ParseString ¶
ParseString converts a string into a snowflake ID
func (ID) Base32 ¶
Base32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func (ID) IntBytes ¶
IntBytes returns an array of bytes of the snowflake ID, encoded as a big endian integer.
func (ID) MarshalJSON ¶
MarshalJSON returns a json byte array string of the snowflake ID.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON converts a json byte array of a snowflake ID into an ID type.
type JSONSyntaxError ¶
type JSONSyntaxError struct {
// contains filtered or unexported fields
}
A JSONSyntaxError is returned from UnmarshalJSON if an invalid ID is provided.
func (JSONSyntaxError) Error ¶
func (j JSONSyntaxError) Error() string
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
A Node struct holds the basic information needed for a snowflake generator node
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) ExistPending ¶
func (*Pool) RunningTasks ¶
func (*Pool) SetMaxWorkerNumber ¶
func (*Pool) WaitAllDone ¶
func (p *Pool) WaitAllDone()
func (*Pool) WaitingTasks ¶
type Process ¶
type Process struct { ExecPath string Args []string Pid int Cmd *exec.Cmd ExitState *os.ProcessState StdinPipe io.WriteCloser StdoutPipe io.ReadCloser StderrPipe io.ReadCloser Cancel context.CancelFunc StopSignal chan bool ExitCode int }