| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package utl
- import (
- "errors"
- "fmt"
- "os"
- "os/signal"
- )
- const (
- FmtTimeStr = "2006-01-02 15:04:05"
- )
- var (
- ErrNotImplemented = errors.New("not implemented yet")
- ErrInterfaceTransform = errors.New("interface transform failed")
- ErrParameters = errors.New("invalid parameters")
- ErrContainerEmpty = errors.New("target container is empty")
- ErrNotExists = errors.New("target not exists")
- )
- type H map[string]interface{}
- type JsReq struct {
- Cmd string `json:"cmd"`
- Seq int64 `json:"seq"`
- Params interface{} `json:"params"`
- }
- type JsResp struct {
- Cmd string `json:"cmd"`
- Seq int64 `json:"seq"`
- Ec int `json:"ec"`
- Result interface{} `json:"result"`
- }
- func ErrForCode(code int) error {
- return errors.New(fmt.Sprintf("returned error code: %v", code))
- }
- func ErrPanic(err error) {
- if err != nil {
- panic(err)
- }
- }
- func UnUsed(v ...interface{}) {
- }
- func WaitForSignals(sigs ...os.Signal) os.Signal {
- chSig := make(chan os.Signal, 1)
- signal.Notify(chSig, sigs...)
- close(chSig)
- sig := <-chSig
- return sig
- }
|