Documentation ¶
Index ¶
- Constants
- func Base64DecodeFilename(src string) ([]byte, error)
- func Base64DecodeMap(str string) (data map[string]interface{}, err error)
- func Base64EncodeFilename(src string) string
- func Base64EncodeMap(data map[string]interface{}) string
- func BasenameWithoutExt(cf string) (base string)
- func BuildInfo(vars ...[2]string) (info [][2]string)
- func CheckDuplicateFilename(p string) (out string, err error)
- func EqualVector[T constraints.Ordered](arr1, arr2 []T) (ok bool)
- func ExampleRequestTmpls() string
- func FileSize2Str(n int64) string
- func First[T any](v []T) *T
- func GetOClock(shift int) (clock time.Time)
- func Hello()
- func Last[T any](v []T) *T
- func ListenOSSignal(ch chan int, sgs ...os.Signal)
- func LoadPprof(mux *http.ServeMux)
- func NTSFunc(delay int64) http.HandlerFunc
- func NowMs() string
- func ParseDatetime(value string) (at time.Time, err error)
- func RandString(n int) string
- func RegisterLogPrinter()
- func RootDir() (dir string, err error)
- func RootFile(p2f ...string) (fp string, err error)
- func RootModule() (mod string, err error)
- func SegnmentsDiv(length, num int) (segs [][2]int)
- func SliceGet[T any](slice []T, index int) (val T, exists bool)
- func Stack(prefix string) (slice []string)
- func TimeCeil(at time.Time, tu string) (out time.Time, err error)
- func TimeFloor(at time.Time, tu string) (out time.Time, err error)
- func UniqVector[T constraints.Ordered](arr []T) (list []T)
- func ValidJSON(bts []byte) (err error)
- func VectorIndex[T constraints.Ordered](list []T, v T) int
- type LogIntf
- type LogPrinter
- type LogWriter
- type Logger
- func (logger *Logger) Debug(format string, a ...any)
- func (logger *Logger) Error(format string, a ...any)
- func (logger *Logger) Info(format string, a ...any)
- func (logger *Logger) Printf(format string, a ...any) (int, error)
- func (logger *Logger) Trace(format string, a ...any)
- func (logger *Logger) Warn(format string, a ...any)
- type NetworkTimeResult
- type NetworkTimeServer
- type Output
- type RequestTmpl
- type RequestTmpls
- type SigningUrlMd5
Constants ¶
View Source
const (
RFC3339ms = "2006-01-02T15:04:05.000Z07:00"
)
Variables ¶
This section is empty.
Functions ¶
func Base64DecodeFilename ¶
replace +/ with -_
func Base64DecodeMap ¶
func Base64EncodeMap ¶
func BasenameWithoutExt ¶
func CheckDuplicateFilename ¶
func EqualVector ¶
func EqualVector[T constraints.Ordered](arr1, arr2 []T) (ok bool)
func ExampleRequestTmpls ¶
func ExampleRequestTmpls() string
func FileSize2Str ¶
func ListenOSSignal ¶
func NTSFunc ¶
func NTSFunc(delay int64) http.HandlerFunc
func ParseDatetime ¶
datetime format: "2021-06-24", "09:00:01", "2021-06-24 09:10:11" or "2021-06-24T09:10:11"
func RandString ¶
func RegisterLogPrinter ¶
func RegisterLogPrinter()
func RootModule ¶
func SegnmentsDiv ¶
func TimeCeil ¶
ceil time, e.g. TimeCeil('2020-12-01T17:39:07.123+08:00', "M") -> '2020-12-01T17:40:00+08:00'
valid unit(key or value) H: hour, M: minute, S: second y: year, s: season, m: month, w: week, d: day
func TimeFloor ¶
floor time, e.g. TimeFloor('2020-12-01T17:39:07.123+08:00', "M") -> '2020-12-01T17:39:00+08:00'
valid unit(key or value) H: hour, M: minute, S: second y: year, s: season, m: month, w: week, d: day
func UniqVector ¶
func UniqVector[T constraints.Ordered](arr []T) (list []T)
func VectorIndex ¶
func VectorIndex[T constraints.Ordered](list []T, v T) int
Types ¶
type LogIntf ¶
type LogIntf interface { Trace(string, ...any) Debug(string, ...any) Info(string, ...any) Warn(string, ...any) Error(string, ...any) }
customize yourself, no concurrency safety guaranteed
type LogPrinter ¶
type LogPrinter struct{}
type LogWriter ¶
type LogWriter struct {
// contains filtered or unexported fields
}
a simple log writer
type NetworkTimeResult ¶
type NetworkTimeResult struct { T1 time.Time `json:"t1"` T2 time.Time `json:"t2"` T3 time.Time `json:"t3"` T4 time.Time `json:"t4"` Sigma int64 `json:"sigma"` Delta int64 `json:"delta"` }
func GetNetworkTime ¶
func GetNetworkTime(addr string, delay int64) (result *NetworkTimeResult, err error)
func (NetworkTimeResult) String ¶
func (result NetworkTimeResult) String() string
type NetworkTimeServer ¶
https://en.wikipedia.org/wiki/Network_Time_Protocol https://en.wikipedia.org/wiki/File:NTP-Algorithm.svg
func NewNetworkTimeServer ¶
func NewNetworkTimeServer(addr string, delay int64) (ser *NetworkTimeServer, err error)
func (*NetworkTimeServer) Run ¶
func (ser *NetworkTimeServer) Run() error
type Output ¶
type RequestTmpl ¶
type RequestTmpl struct { Name string `mapstructure:"name"` Method string `mapstructure:"method"` Path string `mapstructure:"path"` Params map[string]string `mapstructure:"params"` Body string `mapstructure:"body"` NoPublicHeaders bool `mapstructure:"no_public_headers"` Headers map[string]string `mapstructure:"headers"` Outputs []Output `mapstructure:"outputs"` }
type RequestTmpls ¶
type RequestTmpls struct { Url string `mapstructure:"url"` Headers map[string]string `mapstructure:"headers"` Prelude []RequestTmpl `mapstructure:"prelude"` APIs []RequestTmpl `mapstructure:"apis"` // contains filtered or unexported fields }
func LoadRequestTmpls ¶
func LoadRequestTmpls(name, fp string) (item *RequestTmpls, err error)
func (*RequestTmpls) Match ¶
func (item *RequestTmpls) Match(names ...string) (tmpls []*RequestTmpl, err error)
func (*RequestTmpls) Request ¶
func (item *RequestTmpls) Request(tmpl *RequestTmpl) ( statusCode int, body string, err error)
type SigningUrlMd5 ¶
type SigningUrlMd5 struct {
// contains filtered or unexported fields
}
func NewSigningUrlMd5 ¶
func NewSigningUrlMd5(secrete, key string, lowcase bool) SigningUrlMd5
func (*SigningUrlMd5) Sign ¶
func (sign *SigningUrlMd5) Sign(param map[string]string) (query string)
func (*SigningUrlMd5) Verify ¶
func (sign *SigningUrlMd5) Verify(query string) (err error)
Click to show internal directories.
Click to hide internal directories.