Documentation ¶
Overview ¶
gorover implement methods like file path, time range, save data to json, cmd input data, randon string, etc.
Index ¶
- Constants
- Variables
- func Base62Decode(str string) (num int64, err error)
- func Base62Encode(num int64) (result string)
- func BatchJSON(n int, do func([]byte) error) func(interface{}, bool) error
- func BindError(e1, e2 error) (err error)
- func Bts2File(bts []byte, out string) (err error)
- func Columns(array [][]string, prefixSpaces, padding int)
- func DecomposePath(p string) (dir, base, ext string, err error)
- func Divmod(a, b int) (d, m int)
- func FixTimeUnit(in string) (out string, err error)
- func GrowthRatioInPerc(a, b int) (ratio float64)
- func IndexInt(slice []int, value int) (p int)
- func IndexInt64(slice []int64, value int64) (p int)
- func IndexString(slice []string, value string) (p int)
- func InvalidTimeUint() (err error)
- func IsMD5(str string) (err error)
- func IsMD5Lower(str string) (err error)
- func IsMD5Upper(str string) (err error)
- func JsonStr(data interface{}, readable bool) (str string, err error)
- func JsonTo(data interface{}, out io.Writer, readable bool) (err error)
- func JsonToFile(data interface{}, out string, readable bool) (err error)
- func JsonToStdout(data interface{}) (err error)
- func LoadBashrc(fp string) (err error)
- func LogErr(tag string, err error)
- func Param2URL(param map[string]string, secrete, signKey string, ...) (urlQuery string)
- func ParseNTU(str string) (n int64, unit string, err error)
- func Percentage(a, b int64) (per float64)
- func PrintData(data interface{})
- func PrintErr(tag string, err error, items ...interface{})
- func QuerySignInMD5(param map[string]string, secrete, signKey string) (urlQuery string)
- func RandAlphanumeric(length int) string
- func RandomStr(l int, t int) (s string, err error)
- func RealPath(p string) (realpath string, err error)
- func SaveData(d interface{}, p string)
- func SignParamInMD5(param map[string]string, secrete string) (signValue string)
- func Str2File(str, out string) (err error)
- func TimeCeil(from time.Time, tu string) (nt time.Time, err error)
- func TimeConvert(ty, str string) (result string, err error)
- func TimeFloor(from time.Time, tu string) (nt time.Time, err error)
- func TimeScale(from time.Time, str string, cof func(time.Time, string) (time.Time, error)) (nt time.Time, err error)
- func TimeScaleRange(from time.Time, str string, cof func(time.Time, string) (time.Time, error)) (t0, t1 time.Time, err error)
- func TimeWalk(from time.Time, n int64, tu string) (nt time.Time, err error)
- func TimeWalkRange(from time.Time, n int64, tu string) (t0, t1 time.Time, err error)
- func UpdateValue(x *string, mp map[string]string)
- func VerifyQuerySignInMD5(urlQuery string, signKey, secrete string) (param map[string]string, err error)
- type Argi
- type Argx
- type CMSE
- type ClassCode
- type ClassElem
- type Counter
- type Edge
- type End
- type KVShare
- type Logger
- func (logger *Logger) Close() (err error)
- func (logger *Logger) GetIndex() (idx int64)
- func (logger *Logger) Log(tag string, rs ...interface{}) (n int, err error)
- func (logger *Logger) LogBlock(tag string, msg string) (n int, err error)
- func (logger *Logger) SetFile(fp string) (err error)
- func (logger *Logger) SetSep(sep string) (err error)
- func (logger *Logger) SetWriter(w io.Writer, sep string) (err error)
- type Node
- type Start
- type TimeSplitter
- type UpdateTrigger
Constants ¶
const DefaultTimeFormat = "2006-01-02T15:04:05-0700"
Variables ¶
var ()
var CMSE_RELEASE_MODE = true
var DeafultTimeFormat = "[2006-01-02T15:04:05-0700]"
var Rand *rand.Rand
Functions ¶
func Base62Decode ¶
func Base62Encode ¶
func Bts2File ¶
// Save bytes and string to file save []byte to file (and create parent directories)
func DecomposePath ¶
return file parent directory, basename and extend name
func FixTimeUnit ¶
func GrowthRatioInPerc ¶
calculate growth ratio from a to b in percentage
func IndexInt64 ¶
func InvalidTimeUint ¶
func InvalidTimeUint() (err error)
func IsMD5Lower ¶
func IsMD5Upper ¶
func JsonToFile ¶
masharshal data to json([]byte) and save to file, parents directories of file will be created
func JsonToStdout ¶
func JsonToStdout(data interface{}) (err error)
masharshal data to json([]byte) to os.Stdout
func LoadBashrc ¶
reference: https://stackoverflow.com/questions/29995741/how-can-i-source-a-shell-script-using-go
func Percentage ¶
func QuerySignInMD5 ¶
func RandAlphanumeric ¶
generate alphanumeric string with fixed length
func RandomStr ¶
generate random string with fixed length type is a 5 bit length binary number which represent numbers, upper letters, lower letters, special characters and space from lower to higher
func SignParamInMD5 ¶
sort parameter by keys in ASCII, concat all key+value, add secrete in header and tail, then calculate MD5 value of string
func TimeConvert ¶
Convert between int64 and time, type example s2t, t2u,
s for Second, m for Millisecond, u for Microsecond, n for Nanosecond t for time in format 2006-01-02T15:04:05-0700
func TimeScaleRange ¶
func TimeWalkRange ¶
func UpdateValue ¶
Types ¶
type Argi ¶
argument input structure
type CMSE ¶
type CMSE struct { C int `json:"code"` // response code, default 200, https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml M string `json:"message"` // repsonse message to end user S int `json:"subcode"` // specify response subcode, generally, S != 0 when E isn't nil E error `json:"-"` D interface{} `json:"data,omitempty"` Error string `json:"error,omitempty"` //!! response with error when CMSE_RELEASE_MODE = false }
type ClassCode ¶
type ClassCode struct { Code uint64 // contains filtered or unexported fields }
func NewClassCode ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
parallel counter with buffered and RWMutex
func NewCounter ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
type Node ¶
type TimeSplitter ¶
type TimeSplitter struct {
Start, End time.Time
Duration time.Duration
// contains filtered or unexported fields
}
//
func NewTimeSplitter ¶
func (*TimeSplitter) GetNK ¶
func (tsp *TimeSplitter) GetNK() (int64, int64)
type UpdateTrigger ¶
type UpdateTrigger struct {
// contains filtered or unexported fields
}
func NewUpdateTrigger ¶
func (*UpdateTrigger) Expired ¶
func (ut *UpdateTrigger) Expired() bool
func (*UpdateTrigger) ResetInterval ¶
func (ut *UpdateTrigger) ResetInterval(d time.Duration) error
func (*UpdateTrigger) Update ¶
func (ut *UpdateTrigger) Update() (err error)