Documentation
¶
Index ¶
- func All(actions ...func()) func()
- func DefaultBackoff(interval time.Duration) time.Duration
- func Dump(list ...interface{})
- func E(args ...interface{}) []interface{}
- func Exec(name string, args ...string)
- func FileExists(path string) bool
- func IsSyncMapEmpty(s *sync.Map) bool
- func Mkdir(path string) error
- func MustReadBytes(r io.Reader) []byte
- func MustReadJSON(r io.Reader) gjson.Result
- func MustReadString(r io.Reader) string
- func MustToJSON(data interface{}) string
- func MustToJSONBytes(data interface{}) []byte
- func OutputFile(p string, data interface{}) error
- func Pause()
- func RandString(len int) string
- func ReadJSON(r io.Reader) (gjson.Result, error)
- func ReadJSONPathAsString(r io.Reader, path string) (string, error)
- func ReadString(p string) (string, error)
- func Retry(ctx context.Context, s Sleeper, fn func() (stop bool, err error)) error
- func S(tpl string, params ...interface{}) string
- func SDump(v interface{}) string
- func Serve(host string) (string, *http.ServeMux, func())
- func SetCmdStdPipe(cmd *exec.Cmd)
- func Sleep(seconds float64)
- func SyncMapToMap(s *sync.Map) map[string]interface{}
- type Nil
- type Sleeper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶ added in v0.52.0
func All(actions ...func()) func()
All run all actions concurrently, returns the wait function for all actions.
func DefaultBackoff ¶ added in v0.52.0
DefaultBackoff algorithm: A(n) = A(n-1) * random[1.9, 2.1)
func FileExists ¶ added in v0.52.0
FileExists checks if file exists, only for file, not for dir
func MustReadBytes ¶ added in v0.52.0
MustReadBytes from reader
func MustReadJSON ¶ added in v0.52.0
MustReadJSON from reader
func MustReadString ¶ added in v0.52.0
MustReadString from reader
func MustToJSON ¶ added in v0.52.0
func MustToJSON(data interface{}) string
MustToJSON encode data to json string
func MustToJSONBytes ¶ added in v0.52.0
func MustToJSONBytes(data interface{}) []byte
MustToJSONBytes encode data to json bytes
func OutputFile ¶ added in v0.52.0
OutputFile auto creates file if not exists, it will try to detect the data type and auto output binary, string or json
func RandString ¶ added in v0.52.0
RandString generate random string with specified string length
func ReadJSONPathAsString ¶ added in v0.54.0
ReadJSONPathAsString from reader
func ReadString ¶ added in v0.52.0
ReadString reads file as string
func Sleep ¶ added in v0.52.0
func Sleep(seconds float64)
Sleep the goroutine for specified seconds, such as 2.3 seconds
func SyncMapToMap ¶ added in v0.59.0
SyncMapToMap convertor
Types ¶
type Sleeper ¶ added in v0.52.0
Sleeper sleeps for sometime, returns the reason to wake, if ctx is done release resource
func BackoffSleeper ¶ added in v0.52.0
func BackoffSleeper(init, maxInterval time.Duration, algorithm func(time.Duration) time.Duration) Sleeper
BackoffSleeper returns a sleeper that sleeps in a backoff manner every time get called. If algorithm is nil, DefaultBackoff will be used. Set interval and maxInterval to the same value to make it a constant interval sleeper. If maxInterval is not greater than 0, it will wake immediately.
func CountSleeper ¶ added in v0.52.0
CountSleeper wake when counts to max and return