Documentation
¶
Index ¶
- Constants
- Variables
- func All(actions ...func())
- func C(str interface{}, color string) string
- func ClearScreen() error
- func Dump(val interface{})
- func E(args ...interface{}) []interface{}
- func E1(arg interface{}, err error) interface{}
- func Err(v ...interface{})
- func ErrArg(args ...interface{}) error
- func Log(v ...interface{})
- func MustToJSON(data interface{}) string
- func MustToJSONBytes(data interface{}) []byte
- func Noop(_ ...interface{})
- func RandBytes(len int) []byte
- func RandString(len int) string
- func S(tpl string, params ...interface{}) string
- func Sdump(val interface{}) string
- func Try(fn func()) (err interface{})
- type Event
- type JSONResult
- type Nil
- type Observable
- type Subscriber
Constants ¶
View Source
const Version = "v0.19.6"
Version version the project
Variables ¶
View Source
var Stderr = ansi.NewAnsiStderr()
Stderr ...
View Source
var Stdout = ansi.NewAnsiStdout()
Stdout ...
Functions ¶
func E1 ¶
func E1(arg interface{}, err error) interface{}
E1 if the second arg is error panic it, or return the first arg
func MustToJSON ¶ added in v0.16.3
func MustToJSON(data interface{}) string
MustToJSON encode data to json string
func MustToJSONBytes ¶ added in v0.16.3
func MustToJSONBytes(data interface{}) []byte
MustToJSONBytes encode data to json bytes
func RandString ¶
RandString generate random string with specified string length
Types ¶
type JSONResult ¶ added in v0.17.0
JSONResult shortcut for gjson.Result
func JSON ¶
func JSON(data interface{}) JSONResult
JSON parse json for easily access the value from json path
type Observable ¶ added in v0.19.4
type Observable struct {
// contains filtered or unexported fields
}
Observable is a thread-safe event helper
func NewObservable ¶ added in v0.19.5
func NewObservable() *Observable
NewObservable creates a new observable
func (*Observable) Publish ¶ added in v0.19.4
func (o *Observable) Publish(e Event)
Publish event to all subscribers
func (*Observable) Subscribe ¶ added in v0.19.4
func (o *Observable) Subscribe() Subscriber
Subscribe returns a subscriber to emit events
func (*Observable) Unsubscribe ¶ added in v0.19.4
func (o *Observable) Unsubscribe(s *Subscriber)
Unsubscribe from the observable
Click to show internal directories.
Click to hide internal directories.