Documentation ¶
Index ¶
- Variables
- func Expand(s string, mapping func(varName string, default_ string) string) (string, error)
- func InplaceSliceToString(s []byte) string
- func InplaceStringToSlice(s string) []byte
- func Isin(s []string, elem string) bool
- func ShortcutUTF8(s string, max int, suffix string) string
- func ToJSON(o interface{}) string
- func ToPrettyJson(o interface{}) string
- type MultiErr
- func (m *MultiErr) All() (all bool)
- func (m *MultiErr) Error() error
- func (m *MultiErr) Fails() (ids []string)
- func (m *MultiErr) Get(id string) (err error)
- func (m *MultiErr) GetE(id string) (err error, ok bool)
- func (m *MultiErr) Range(f func(id string, err error) bool)
- func (m *MultiErr) Set(id string, err error)
- func (m *MultiErr) String() string
- func (m *MultiErr) Successes() (ids []string)
Constants ¶
This section is empty.
Variables ¶
var ToPrettyJSON = ToPrettyJson
ToPrettyJSON likes ToJSON with pretty output
Functions ¶
func Expand ¶
Expand replaces ${var} in the template string base on the mapping function.
It's like os.Expand but with following differences:
- strict syntax checks, return the string replaces as many as we can, and an syntax error.
- compatible with bash like ${var:=default} syntax.
- $var outputs as is.
func InplaceSliceToString ¶
InplaceSliceToString transfer []byte into string inplace
func InplaceStringToSlice ¶
InplaceStringToSlice transfer string into []byte inplace
func ShortcutUTF8 ¶ added in v0.6.0
ShortcutUTF8 return a valid UTF-8 string with at most `max` + len(suffix) characters.
If `s` has more than `max` characters, cuts it to max and add `suffix`. Multibyte characters are handled resonable. If `max` is lower than 0, then return `s`.
func ToJSON ¶
func ToJSON(o interface{}) string
ToJSON return the object json marshal not HTML escaped string. An empty string returned if there is a marshal error.
func ToPrettyJson ¶
func ToPrettyJson(o interface{}) string
ToPrettyJson like ToJSON with pretty output
Types ¶
type MultiErr ¶ added in v0.6.0
type MultiErr struct {
// contains filtered or unexported fields
}
MultiErr represent a bucket of errors. Usually it should be used as follow:
var m MultiErr for _, id := range []string{"1", "2"} { id := id go func1() { err := somefunc1(id) m.Set(id, err) } } MultiErr all method is goroutine-safe(lock-guarded).
func (*MultiErr) Error ¶ added in v0.6.0
Error returns an error. It returns nil if All returns true.
Directories ¶
Path | Synopsis |
---|---|
Package assert provide function useful for unit testing.
|
Package assert provide function useful for unit testing. |
Package bloom provides a bloom filter implementation inspired by leveldb.
|
Package bloom provides a bloom filter implementation inspired by leveldb. |
Package hedging provides a method to get an no-error answer from two functions.
|
Package hedging provides a method to get an no-error answer from two functions. |
internal
|
|
Package set implements wild-used set container.
|
Package set implements wild-used set container. |
Package strings contains a bucket of operations of string.
|
Package strings contains a bucket of operations of string. |