id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
150,500
tideland/golib
redis/values.go
Bool
func (v Value) Bool() (bool, error) { b, err := strconv.ParseBool(v.String()) if err != nil { return false, v.invalidTypeError(err, "bool") } return b, nil }
go
func (v Value) Bool() (bool, error) { b, err := strconv.ParseBool(v.String()) if err != nil { return false, v.invalidTypeError(err, "bool") } return b, nil }
[ "func", "(", "v", "Value", ")", "Bool", "(", ")", "(", "bool", ",", "error", ")", "{", "b", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "v", ".", "String", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "v...
// Bool return the value as bool.
[ "Bool", "return", "the", "value", "as", "bool", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L53-L59
150,501
tideland/golib
redis/values.go
Int
func (v Value) Int() (int, error) { i, err := strconv.Atoi(v.String()) if err != nil { return 0, v.invalidTypeError(err, "int") } return i, nil }
go
func (v Value) Int() (int, error) { i, err := strconv.Atoi(v.String()) if err != nil { return 0, v.invalidTypeError(err, "int") } return i, nil }
[ "func", "(", "v", "Value", ")", "Int", "(", ")", "(", "int", ",", "error", ")", "{", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "v", ".", "String", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "v", ".", ...
// Int returns the value as int.
[ "Int", "returns", "the", "value", "as", "int", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L62-L68
150,502
tideland/golib
redis/values.go
Int64
func (v Value) Int64() (int64, error) { i, err := strconv.ParseInt(v.String(), 10, 64) if err != nil { return 0, v.invalidTypeError(err, "int64") } return i, nil }
go
func (v Value) Int64() (int64, error) { i, err := strconv.ParseInt(v.String(), 10, 64) if err != nil { return 0, v.invalidTypeError(err, "int64") } return i, nil }
[ "func", "(", "v", "Value", ")", "Int64", "(", ")", "(", "int64", ",", "error", ")", "{", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "v", ".", "String", "(", ")", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "...
// Int64 returns the value as int64.
[ "Int64", "returns", "the", "value", "as", "int64", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L71-L77
150,503
tideland/golib
redis/values.go
Uint64
func (v Value) Uint64() (uint64, error) { i, err := strconv.ParseUint(v.String(), 10, 64) if err != nil { return 0, v.invalidTypeError(err, "uint64") } return i, nil }
go
func (v Value) Uint64() (uint64, error) { i, err := strconv.ParseUint(v.String(), 10, 64) if err != nil { return 0, v.invalidTypeError(err, "uint64") } return i, nil }
[ "func", "(", "v", "Value", ")", "Uint64", "(", ")", "(", "uint64", ",", "error", ")", "{", "i", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "v", ".", "String", "(", ")", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", ...
// Uint64 returns the value as uint64.
[ "Uint64", "returns", "the", "value", "as", "uint64", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L80-L86
150,504
tideland/golib
redis/values.go
Float64
func (v Value) Float64() (float64, error) { f, err := strconv.ParseFloat(v.String(), 64) if err != nil { return 0.0, v.invalidTypeError(err, "float64") } return f, nil }
go
func (v Value) Float64() (float64, error) { f, err := strconv.ParseFloat(v.String(), 64) if err != nil { return 0.0, v.invalidTypeError(err, "float64") } return f, nil }
[ "func", "(", "v", "Value", ")", "Float64", "(", ")", "(", "float64", ",", "error", ")", "{", "f", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "v", ".", "String", "(", ")", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Float64 returns the value as float64.
[ "Float64", "returns", "the", "value", "as", "float64", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L89-L95
150,505
tideland/golib
redis/values.go
StringMap
func (v Value) StringMap() map[string]string { tmp := v.StringSlice() m := make(map[string]string, len(tmp)) for _, s := range tmp { kv := strings.Split(s, ":") if len(kv) > 1 { m[strings.TrimSpace(kv[0])] = strings.TrimSpace(kv[1]) } } return m }
go
func (v Value) StringMap() map[string]string { tmp := v.StringSlice() m := make(map[string]string, len(tmp)) for _, s := range tmp { kv := strings.Split(s, ":") if len(kv) > 1 { m[strings.TrimSpace(kv[0])] = strings.TrimSpace(kv[1]) } } return m }
[ "func", "(", "v", "Value", ")", "StringMap", "(", ")", "map", "[", "string", "]", "string", "{", "tmp", ":=", "v", ".", "StringSlice", "(", ")", "\n", "m", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "tmp", ")", ")"...
// StringMap returns the value as a map of strings when separated by CRLF // and colons between key and value.
[ "StringMap", "returns", "the", "value", "as", "a", "map", "of", "strings", "when", "separated", "by", "CRLF", "and", "colons", "between", "key", "and", "value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L109-L119
150,506
tideland/golib
redis/values.go
Unpack
func (v Value) Unpack() Value { if len(v) > 2 && v[0] == '[' && v[len(v)-1] == ']' { return Value(v[1 : len(v)-1]) } return v }
go
func (v Value) Unpack() Value { if len(v) > 2 && v[0] == '[' && v[len(v)-1] == ']' { return Value(v[1 : len(v)-1]) } return v }
[ "func", "(", "v", "Value", ")", "Unpack", "(", ")", "Value", "{", "if", "len", "(", "v", ")", ">", "2", "&&", "v", "[", "0", "]", "==", "'['", "&&", "v", "[", "len", "(", "v", ")", "-", "1", "]", "==", "']'", "{", "return", "Value", "(", ...
// Unpack removes the braces of a list value.
[ "Unpack", "removes", "the", "braces", "of", "a", "list", "value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L122-L127
150,507
tideland/golib
redis/values.go
invalidTypeError
func (v Value) invalidTypeError(err error, descr string) error { return errors.Annotate(err, ErrInvalidType, errorMessages, v.String(), descr) }
go
func (v Value) invalidTypeError(err error, descr string) error { return errors.Annotate(err, ErrInvalidType, errorMessages, v.String(), descr) }
[ "func", "(", "v", "Value", ")", "invalidTypeError", "(", "err", "error", ",", "descr", "string", ")", "error", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "ErrInvalidType", ",", "errorMessages", ",", "v", ".", "String", "(", ")", ",", "d...
// invalidTypeError returns an annotated error if a value access has // been unsuccessful.
[ "invalidTypeError", "returns", "an", "annotated", "error", "if", "a", "value", "access", "has", "been", "unsuccessful", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L131-L133
150,508
tideland/golib
redis/values.go
Strings
func (vs Values) Strings() []string { ss := make([]string, len(vs)) for i, v := range vs { ss[i] = v.String() } return ss }
go
func (vs Values) Strings() []string { ss := make([]string, len(vs)) for i, v := range vs { ss[i] = v.String() } return ss }
[ "func", "(", "vs", "Values", ")", "Strings", "(", ")", "[", "]", "string", "{", "ss", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "vs", ")", ")", "\n", "for", "i", ",", "v", ":=", "range", "vs", "{", "ss", "[", "i", "]", "=", ...
// Strings returns all values as strings.
[ "Strings", "returns", "all", "values", "as", "strings", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L144-L150
150,509
tideland/golib
redis/values.go
String
func (sv ScoredValue) String() string { return fmt.Sprintf("%v (%f)", sv.Value, sv.Score) }
go
func (sv ScoredValue) String() string { return fmt.Sprintf("%v (%f)", sv.Value, sv.Score) }
[ "func", "(", "sv", "ScoredValue", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sv", ".", "Value", ",", "sv", ".", "Score", ")", "\n", "}" ]
// String returs the scored value as string.
[ "String", "returs", "the", "scored", "value", "as", "string", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L195-L197
150,510
tideland/golib
redis/values.go
String
func (svs ScoredValues) String() string { svss := []string{} for _, sv := range svs { svss = append(svss, sv.String()) } return fmt.Sprintf("[%s]", strings.Join(svss, " / ")) }
go
func (svs ScoredValues) String() string { svss := []string{} for _, sv := range svs { svss = append(svss, sv.String()) } return fmt.Sprintf("[%s]", strings.Join(svss, " / ")) }
[ "func", "(", "svs", "ScoredValues", ")", "String", "(", ")", "string", "{", "svss", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "sv", ":=", "range", "svs", "{", "svss", "=", "append", "(", "svss", ",", "sv", ".", "String", "(", "...
// String returs the scored values as string.
[ "String", "returs", "the", "scored", "values", "as", "string", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L208-L214
150,511
tideland/golib
redis/values.go
NewFilledHash
func NewFilledHash(kvs map[string]interface{}) Hash { h := NewHash() for k, v := range kvs { h.Set(k, v) } return h }
go
func NewFilledHash(kvs map[string]interface{}) Hash { h := NewHash() for k, v := range kvs { h.Set(k, v) } return h }
[ "func", "NewFilledHash", "(", "kvs", "map", "[", "string", "]", "interface", "{", "}", ")", "Hash", "{", "h", ":=", "NewHash", "(", ")", "\n", "for", "k", ",", "v", ":=", "range", "kvs", "{", "h", ".", "Set", "(", "k", ",", "v", ")", "\n", "}...
// NewFilledHash creates a hash with the passed keys and values.
[ "NewFilledHash", "creates", "a", "hash", "with", "the", "passed", "keys", "and", "values", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L230-L236
150,512
tideland/golib
redis/values.go
Set
func (h Hash) Set(key string, value interface{}) Hash { h[key] = Value(valueToBytes(value)) return h }
go
func (h Hash) Set(key string, value interface{}) Hash { h[key] = Value(valueToBytes(value)) return h }
[ "func", "(", "h", "Hash", ")", "Set", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "Hash", "{", "h", "[", "key", "]", "=", "Value", "(", "valueToBytes", "(", "value", ")", ")", "\n", "return", "h", "\n", "}" ]
// Set sets a key to the given value.
[ "Set", "sets", "a", "key", "to", "the", "given", "value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L244-L247
150,513
tideland/golib
redis/values.go
String
func (h Hash) String(key string) (string, error) { if value, ok := h[key]; ok { return value.String(), nil } return "", errors.New(ErrInvalidKey, errorMessages, key) }
go
func (h Hash) String(key string) (string, error) { if value, ok := h[key]; ok { return value.String(), nil } return "", errors.New(ErrInvalidKey, errorMessages, key) }
[ "func", "(", "h", "Hash", ")", "String", "(", "key", "string", ")", "(", "string", ",", "error", ")", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "String", "(", ")", ",", "nil", "\n", "}"...
// String returns the value of a key as string.
[ "String", "returns", "the", "value", "of", "a", "key", "as", "string", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L250-L255
150,514
tideland/golib
redis/values.go
Bool
func (h Hash) Bool(key string) (bool, error) { if value, ok := h[key]; ok { return value.Bool() } return false, errors.New(ErrInvalidKey, errorMessages, key) }
go
func (h Hash) Bool(key string) (bool, error) { if value, ok := h[key]; ok { return value.Bool() } return false, errors.New(ErrInvalidKey, errorMessages, key) }
[ "func", "(", "h", "Hash", ")", "Bool", "(", "key", "string", ")", "(", "bool", ",", "error", ")", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "Bool", "(", ")", "\n", "}", "\n", "return", ...
// Bool returns the value of a key as bool.
[ "Bool", "returns", "the", "value", "of", "a", "key", "as", "bool", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L258-L263
150,515
tideland/golib
redis/values.go
Int
func (h Hash) Int(key string) (int, error) { if value, ok := h[key]; ok { return value.Int() } return 0, errors.New(ErrInvalidKey, errorMessages, key) }
go
func (h Hash) Int(key string) (int, error) { if value, ok := h[key]; ok { return value.Int() } return 0, errors.New(ErrInvalidKey, errorMessages, key) }
[ "func", "(", "h", "Hash", ")", "Int", "(", "key", "string", ")", "(", "int", ",", "error", ")", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "Int", "(", ")", "\n", "}", "\n", "return", "...
// Int returns the value of a key as int.
[ "Int", "returns", "the", "value", "of", "a", "key", "as", "int", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L266-L271
150,516
tideland/golib
redis/values.go
Int64
func (h Hash) Int64(key string) (int64, error) { if value, ok := h[key]; ok { return value.Int64() } return 0, errors.New(ErrInvalidKey, errorMessages, key) }
go
func (h Hash) Int64(key string) (int64, error) { if value, ok := h[key]; ok { return value.Int64() } return 0, errors.New(ErrInvalidKey, errorMessages, key) }
[ "func", "(", "h", "Hash", ")", "Int64", "(", "key", "string", ")", "(", "int64", ",", "error", ")", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "Int64", "(", ")", "\n", "}", "\n", "return...
// Int64 returns the value of a key as int64.
[ "Int64", "returns", "the", "value", "of", "a", "key", "as", "int64", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L274-L279
150,517
tideland/golib
redis/values.go
Uint64
func (h Hash) Uint64(key string) (uint64, error) { if value, ok := h[key]; ok { return value.Uint64() } return 0, errors.New(ErrInvalidKey, errorMessages, key) }
go
func (h Hash) Uint64(key string) (uint64, error) { if value, ok := h[key]; ok { return value.Uint64() } return 0, errors.New(ErrInvalidKey, errorMessages, key) }
[ "func", "(", "h", "Hash", ")", "Uint64", "(", "key", "string", ")", "(", "uint64", ",", "error", ")", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "Uint64", "(", ")", "\n", "}", "\n", "ret...
// Uint64 returns the value of a key as uint64.
[ "Uint64", "returns", "the", "value", "of", "a", "key", "as", "uint64", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L282-L287
150,518
tideland/golib
redis/values.go
Float64
func (h Hash) Float64(key string) (float64, error) { if value, ok := h[key]; ok { return value.Float64() } return 0.0, errors.New(ErrInvalidKey, errorMessages, key) }
go
func (h Hash) Float64(key string) (float64, error) { if value, ok := h[key]; ok { return value.Float64() } return 0.0, errors.New(ErrInvalidKey, errorMessages, key) }
[ "func", "(", "h", "Hash", ")", "Float64", "(", "key", "string", ")", "(", "float64", ",", "error", ")", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "Float64", "(", ")", "\n", "}", "\n", "...
// Float64 returns the value of a key as float64.
[ "Float64", "returns", "the", "value", "of", "a", "key", "as", "float64", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L290-L295
150,519
tideland/golib
redis/values.go
Bytes
func (h Hash) Bytes(key string) []byte { if value, ok := h[key]; ok { return value.Bytes() } return []byte{} }
go
func (h Hash) Bytes(key string) []byte { if value, ok := h[key]; ok { return value.Bytes() } return []byte{} }
[ "func", "(", "h", "Hash", ")", "Bytes", "(", "key", "string", ")", "[", "]", "byte", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "Bytes", "(", ")", "\n", "}", "\n", "return", "[", "]", ...
// Bytes returns the value of a key as byte slice.
[ "Bytes", "returns", "the", "value", "of", "a", "key", "as", "byte", "slice", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L298-L303
150,520
tideland/golib
redis/values.go
StringSlice
func (h Hash) StringSlice(key string) []string { if value, ok := h[key]; ok { return value.StringSlice() } return []string{} }
go
func (h Hash) StringSlice(key string) []string { if value, ok := h[key]; ok { return value.StringSlice() } return []string{} }
[ "func", "(", "h", "Hash", ")", "StringSlice", "(", "key", "string", ")", "[", "]", "string", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "StringSlice", "(", ")", "\n", "}", "\n", "return", ...
// StringSlice returns the value of a key as string slice.
[ "StringSlice", "returns", "the", "value", "of", "a", "key", "as", "string", "slice", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L306-L311
150,521
tideland/golib
redis/values.go
StringMap
func (h Hash) StringMap(key string) map[string]string { if value, ok := h[key]; ok { return value.StringMap() } return map[string]string{} }
go
func (h Hash) StringMap(key string) map[string]string { if value, ok := h[key]; ok { return value.StringMap() } return map[string]string{} }
[ "func", "(", "h", "Hash", ")", "StringMap", "(", "key", "string", ")", "map", "[", "string", "]", "string", "{", "if", "value", ",", "ok", ":=", "h", "[", "key", "]", ";", "ok", "{", "return", "value", ".", "StringMap", "(", ")", "\n", "}", "\n...
// StringMap returns the value of a key as string map.
[ "StringMap", "returns", "the", "value", "of", "a", "key", "as", "string", "map", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/values.go#L314-L319
150,522
tideland/golib
audit/asserts.go
SetFailable
func (a *assertion) SetFailable(f Failable) func() { tf, ok := a.failer.(*testingFailer) if !ok { // Nothing to do. return func() {} } // It's a test assertion. old := tf.failable tf.failable = f return func() { tf.failable = old } }
go
func (a *assertion) SetFailable(f Failable) func() { tf, ok := a.failer.(*testingFailer) if !ok { // Nothing to do. return func() {} } // It's a test assertion. old := tf.failable tf.failable = f return func() { tf.failable = old } }
[ "func", "(", "a", "*", "assertion", ")", "SetFailable", "(", "f", "Failable", ")", "func", "(", ")", "{", "tf", ",", "ok", ":=", "a", ".", "failer", ".", "(", "*", "testingFailer", ")", "\n", "if", "!", "ok", "{", "// Nothing to do.", "return", "fu...
// SetFailable implements Assertion.
[ "SetFailable", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L197-L209
150,523
tideland/golib
audit/asserts.go
Logf
func (a *assertion) Logf(format string, args ...interface{}) { a.failer.Logf(format, args...) }
go
func (a *assertion) Logf(format string, args ...interface{}) { a.failer.Logf(format, args...) }
[ "func", "(", "a", "*", "assertion", ")", "Logf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "a", ".", "failer", ".", "Logf", "(", "format", ",", "args", "...", ")", "\n", "}" ]
// Logf implements Assertion.
[ "Logf", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L217-L219
150,524
tideland/golib
audit/asserts.go
True
func (a *assertion) True(obtained bool, msgs ...string) bool { if !a.IsTrue(obtained) { return a.failer.Fail(True, obtained, true, msgs...) } return true }
go
func (a *assertion) True(obtained bool, msgs ...string) bool { if !a.IsTrue(obtained) { return a.failer.Fail(True, obtained, true, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "True", "(", "obtained", "bool", ",", "msgs", "...", "string", ")", "bool", "{", "if", "!", "a", ".", "IsTrue", "(", "obtained", ")", "{", "return", "a", ".", "failer", ".", "Fail", "(", "True", ",", "obta...
// True implements Assertion.
[ "True", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L222-L227
150,525
tideland/golib
audit/asserts.go
False
func (a *assertion) False(obtained bool, msgs ...string) bool { if a.IsTrue(obtained) { return a.failer.Fail(False, obtained, false, msgs...) } return true }
go
func (a *assertion) False(obtained bool, msgs ...string) bool { if a.IsTrue(obtained) { return a.failer.Fail(False, obtained, false, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "False", "(", "obtained", "bool", ",", "msgs", "...", "string", ")", "bool", "{", "if", "a", ".", "IsTrue", "(", "obtained", ")", "{", "return", "a", ".", "failer", ".", "Fail", "(", "False", ",", "obtained"...
// False implements Assertion.
[ "False", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L230-L235
150,526
tideland/golib
audit/asserts.go
Nil
func (a *assertion) Nil(obtained interface{}, msgs ...string) bool { if !a.IsNil(obtained) { return a.failer.Fail(Nil, obtained, nil, msgs...) } return true }
go
func (a *assertion) Nil(obtained interface{}, msgs ...string) bool { if !a.IsNil(obtained) { return a.failer.Fail(Nil, obtained, nil, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Nil", "(", "obtained", "interface", "{", "}", ",", "msgs", "...", "string", ")", "bool", "{", "if", "!", "a", ".", "IsNil", "(", "obtained", ")", "{", "return", "a", ".", "failer", ".", "Fail", "(", "Nil"...
// Nil implements Assertion.
[ "Nil", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L238-L243
150,527
tideland/golib
audit/asserts.go
Equal
func (a *assertion) Equal(obtained, expected interface{}, msgs ...string) bool { if !a.IsEqual(obtained, expected) { return a.failer.Fail(Equal, obtained, expected, msgs...) } return true }
go
func (a *assertion) Equal(obtained, expected interface{}, msgs ...string) bool { if !a.IsEqual(obtained, expected) { return a.failer.Fail(Equal, obtained, expected, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Equal", "(", "obtained", ",", "expected", "interface", "{", "}", ",", "msgs", "...", "string", ")", "bool", "{", "if", "!", "a", ".", "IsEqual", "(", "obtained", ",", "expected", ")", "{", "return", "a", "....
// Equal implements Assertion.
[ "Equal", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L254-L259
150,528
tideland/golib
audit/asserts.go
Contents
func (a *assertion) Contents(part, full interface{}, msgs ...string) bool { contains, err := a.Contains(part, full) if err != nil { return a.failer.Fail(Contents, part, full, "type missmatch: "+err.Error()) } if !contains { return a.failer.Fail(Contents, part, full, msgs...) } return true }
go
func (a *assertion) Contents(part, full interface{}, msgs ...string) bool { contains, err := a.Contains(part, full) if err != nil { return a.failer.Fail(Contents, part, full, "type missmatch: "+err.Error()) } if !contains { return a.failer.Fail(Contents, part, full, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Contents", "(", "part", ",", "full", "interface", "{", "}", ",", "msgs", "...", "string", ")", "bool", "{", "contains", ",", "err", ":=", "a", ".", "Contains", "(", "part", ",", "full", ")", "\n", "if", "...
// Contents implements Assertion.
[ "Contents", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L270-L279
150,529
tideland/golib
audit/asserts.go
About
func (a *assertion) About(obtained, expected, extent float64, msgs ...string) bool { if !a.IsAbout(obtained, expected, extent) { return a.failer.Fail(About, obtained, expected, msgs...) } return true }
go
func (a *assertion) About(obtained, expected, extent float64, msgs ...string) bool { if !a.IsAbout(obtained, expected, extent) { return a.failer.Fail(About, obtained, expected, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "About", "(", "obtained", ",", "expected", ",", "extent", "float64", ",", "msgs", "...", "string", ")", "bool", "{", "if", "!", "a", ".", "IsAbout", "(", "obtained", ",", "expected", ",", "extent", ")", "{", ...
// About implements Assertion.
[ "About", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L282-L287
150,530
tideland/golib
audit/asserts.go
Range
func (a *assertion) Range(obtained, low, high interface{}, msgs ...string) bool { expected := &lowHigh{low, high} inRange, err := a.IsInRange(obtained, low, high) if err != nil { return a.failer.Fail(Range, obtained, expected, "type missmatch: "+err.Error()) } if !inRange { return a.failer.Fail(Range, obtained...
go
func (a *assertion) Range(obtained, low, high interface{}, msgs ...string) bool { expected := &lowHigh{low, high} inRange, err := a.IsInRange(obtained, low, high) if err != nil { return a.failer.Fail(Range, obtained, expected, "type missmatch: "+err.Error()) } if !inRange { return a.failer.Fail(Range, obtained...
[ "func", "(", "a", "*", "assertion", ")", "Range", "(", "obtained", ",", "low", ",", "high", "interface", "{", "}", ",", "msgs", "...", "string", ")", "bool", "{", "expected", ":=", "&", "lowHigh", "{", "low", ",", "high", "}", "\n", "inRange", ",",...
// Range implements Assertion.
[ "Range", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L290-L300
150,531
tideland/golib
audit/asserts.go
Substring
func (a *assertion) Substring(obtained, full string, msgs ...string) bool { if !a.IsSubstring(obtained, full) { return a.failer.Fail(Substring, obtained, full, msgs...) } return true }
go
func (a *assertion) Substring(obtained, full string, msgs ...string) bool { if !a.IsSubstring(obtained, full) { return a.failer.Fail(Substring, obtained, full, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Substring", "(", "obtained", ",", "full", "string", ",", "msgs", "...", "string", ")", "bool", "{", "if", "!", "a", ".", "IsSubstring", "(", "obtained", ",", "full", ")", "{", "return", "a", ".", "failer", ...
// Substring implements Assertion.
[ "Substring", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L303-L308
150,532
tideland/golib
audit/asserts.go
Case
func (a *assertion) Case(obtained string, upperCase bool, msgs ...string) bool { if !a.IsCase(obtained, upperCase) { if upperCase { return a.failer.Fail(Case, obtained, strings.ToUpper(obtained), msgs...) } return a.failer.Fail(Case, obtained, strings.ToLower(obtained), msgs...) } return true }
go
func (a *assertion) Case(obtained string, upperCase bool, msgs ...string) bool { if !a.IsCase(obtained, upperCase) { if upperCase { return a.failer.Fail(Case, obtained, strings.ToUpper(obtained), msgs...) } return a.failer.Fail(Case, obtained, strings.ToLower(obtained), msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Case", "(", "obtained", "string", ",", "upperCase", "bool", ",", "msgs", "...", "string", ")", "bool", "{", "if", "!", "a", ".", "IsCase", "(", "obtained", ",", "upperCase", ")", "{", "if", "upperCase", "{", ...
// Case implements Assertion.
[ "Case", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L311-L319
150,533
tideland/golib
audit/asserts.go
Match
func (a *assertion) Match(obtained, regex string, msgs ...string) bool { matches, err := a.IsMatching(obtained, regex) if err != nil { return a.failer.Fail(Match, obtained, regex, "can't compile regex: "+err.Error()) } if !matches { return a.failer.Fail(Match, obtained, regex, msgs...) } return true }
go
func (a *assertion) Match(obtained, regex string, msgs ...string) bool { matches, err := a.IsMatching(obtained, regex) if err != nil { return a.failer.Fail(Match, obtained, regex, "can't compile regex: "+err.Error()) } if !matches { return a.failer.Fail(Match, obtained, regex, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Match", "(", "obtained", ",", "regex", "string", ",", "msgs", "...", "string", ")", "bool", "{", "matches", ",", "err", ":=", "a", ".", "IsMatching", "(", "obtained", ",", "regex", ")", "\n", "if", "err", "...
// Match implements Assertion.
[ "Match", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L322-L331
150,534
tideland/golib
audit/asserts.go
ErrorMatch
func (a *assertion) ErrorMatch(obtained error, regex string, msgs ...string) bool { if obtained == nil { return a.failer.Fail(ErrorMatch, nil, regex, "error is nil") } matches, err := a.IsMatching(obtained.Error(), regex) if err != nil { return a.failer.Fail(ErrorMatch, obtained, regex, "can't compile regex: "+...
go
func (a *assertion) ErrorMatch(obtained error, regex string, msgs ...string) bool { if obtained == nil { return a.failer.Fail(ErrorMatch, nil, regex, "error is nil") } matches, err := a.IsMatching(obtained.Error(), regex) if err != nil { return a.failer.Fail(ErrorMatch, obtained, regex, "can't compile regex: "+...
[ "func", "(", "a", "*", "assertion", ")", "ErrorMatch", "(", "obtained", "error", ",", "regex", "string", ",", "msgs", "...", "string", ")", "bool", "{", "if", "obtained", "==", "nil", "{", "return", "a", ".", "failer", ".", "Fail", "(", "ErrorMatch", ...
// ErrorMatch implements Assertion.
[ "ErrorMatch", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L334-L346
150,535
tideland/golib
audit/asserts.go
Implementor
func (a *assertion) Implementor(obtained, expected interface{}, msgs ...string) bool { implements, err := a.IsImplementor(obtained, expected) if err != nil { return a.failer.Fail(Implementor, obtained, expected, err.Error()) } if !implements { return a.failer.Fail(Implementor, obtained, expected, msgs...) } r...
go
func (a *assertion) Implementor(obtained, expected interface{}, msgs ...string) bool { implements, err := a.IsImplementor(obtained, expected) if err != nil { return a.failer.Fail(Implementor, obtained, expected, err.Error()) } if !implements { return a.failer.Fail(Implementor, obtained, expected, msgs...) } r...
[ "func", "(", "a", "*", "assertion", ")", "Implementor", "(", "obtained", ",", "expected", "interface", "{", "}", ",", "msgs", "...", "string", ")", "bool", "{", "implements", ",", "err", ":=", "a", ".", "IsImplementor", "(", "obtained", ",", "expected", ...
// Implementor implements Assertion.
[ "Implementor", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L349-L358
150,536
tideland/golib
audit/asserts.go
Assignable
func (a *assertion) Assignable(obtained, expected interface{}, msgs ...string) bool { if !a.IsAssignable(obtained, expected) { return a.failer.Fail(Assignable, obtained, expected, msgs...) } return true }
go
func (a *assertion) Assignable(obtained, expected interface{}, msgs ...string) bool { if !a.IsAssignable(obtained, expected) { return a.failer.Fail(Assignable, obtained, expected, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Assignable", "(", "obtained", ",", "expected", "interface", "{", "}", ",", "msgs", "...", "string", ")", "bool", "{", "if", "!", "a", ".", "IsAssignable", "(", "obtained", ",", "expected", ")", "{", "return", ...
// Assignable implements Assertion.
[ "Assignable", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L361-L366
150,537
tideland/golib
audit/asserts.go
NotEmpty
func (a *assertion) NotEmpty(obtained interface{}, msgs ...string) bool { length, err := a.Len(obtained) if err != nil { return a.failer.Fail(NotEmpty, ValueDescription(obtained), 0, err.Error()) } if length == 0 { return a.failer.Fail(NotEmpty, length, 0, msgs...) } return true }
go
func (a *assertion) NotEmpty(obtained interface{}, msgs ...string) bool { length, err := a.Len(obtained) if err != nil { return a.failer.Fail(NotEmpty, ValueDescription(obtained), 0, err.Error()) } if length == 0 { return a.failer.Fail(NotEmpty, length, 0, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "NotEmpty", "(", "obtained", "interface", "{", "}", ",", "msgs", "...", "string", ")", "bool", "{", "length", ",", "err", ":=", "a", ".", "Len", "(", "obtained", ")", "\n", "if", "err", "!=", "nil", "{", "...
// NotEmpty implements Assertion.
[ "NotEmpty", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L390-L400
150,538
tideland/golib
audit/asserts.go
Length
func (a *assertion) Length(obtained interface{}, expected int, msgs ...string) bool { length, err := a.Len(obtained) if err != nil { return a.failer.Fail(Length, ValueDescription(obtained), expected, err.Error()) } if length != expected { return a.failer.Fail(Length, length, expected, msgs...) } return true }
go
func (a *assertion) Length(obtained interface{}, expected int, msgs ...string) bool { length, err := a.Len(obtained) if err != nil { return a.failer.Fail(Length, ValueDescription(obtained), expected, err.Error()) } if length != expected { return a.failer.Fail(Length, length, expected, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Length", "(", "obtained", "interface", "{", "}", ",", "expected", "int", ",", "msgs", "...", "string", ")", "bool", "{", "length", ",", "err", ":=", "a", ".", "Len", "(", "obtained", ")", "\n", "if", "err",...
// Length implements Assertion.
[ "Length", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L403-L412
150,539
tideland/golib
audit/asserts.go
Panics
func (a *assertion) Panics(pf func(), msgs ...string) bool { if !a.HasPanic(pf) { return a.failer.Fail(Panics, ValueDescription(pf), nil, msgs...) } return true }
go
func (a *assertion) Panics(pf func(), msgs ...string) bool { if !a.HasPanic(pf) { return a.failer.Fail(Panics, ValueDescription(pf), nil, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "Panics", "(", "pf", "func", "(", ")", ",", "msgs", "...", "string", ")", "bool", "{", "if", "!", "a", ".", "HasPanic", "(", "pf", ")", "{", "return", "a", ".", "failer", ".", "Fail", "(", "Panics", ",",...
// Panics implements Assertion.
[ "Panics", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L415-L420
150,540
tideland/golib
audit/asserts.go
PathExists
func (a *assertion) PathExists(obtained string, msgs ...string) bool { valid, err := a.IsValidPath(obtained) if err != nil { return a.failer.Fail(PathExists, obtained, true, err.Error()) } if !valid { return a.failer.Fail(PathExists, obtained, true, msgs...) } return true }
go
func (a *assertion) PathExists(obtained string, msgs ...string) bool { valid, err := a.IsValidPath(obtained) if err != nil { return a.failer.Fail(PathExists, obtained, true, err.Error()) } if !valid { return a.failer.Fail(PathExists, obtained, true, msgs...) } return true }
[ "func", "(", "a", "*", "assertion", ")", "PathExists", "(", "obtained", "string", ",", "msgs", "...", "string", ")", "bool", "{", "valid", ",", "err", ":=", "a", ".", "IsValidPath", "(", "obtained", ")", "\n", "if", "err", "!=", "nil", "{", "return",...
// PathExists implements Assertion.
[ "PathExists", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L423-L432
150,541
tideland/golib
audit/asserts.go
Wait
func (a *assertion) Wait(sigc <-chan interface{}, expected interface{}, timeout time.Duration, msgs ...string) bool { select { case obtained := <-sigc: if !a.IsEqual(obtained, expected) { return a.failer.Fail(Wait, obtained, expected, msgs...) } return true case <-time.After(timeout): return a.failer.Fail...
go
func (a *assertion) Wait(sigc <-chan interface{}, expected interface{}, timeout time.Duration, msgs ...string) bool { select { case obtained := <-sigc: if !a.IsEqual(obtained, expected) { return a.failer.Fail(Wait, obtained, expected, msgs...) } return true case <-time.After(timeout): return a.failer.Fail...
[ "func", "(", "a", "*", "assertion", ")", "Wait", "(", "sigc", "<-", "chan", "interface", "{", "}", ",", "expected", "interface", "{", "}", ",", "timeout", "time", ".", "Duration", ",", "msgs", "...", "string", ")", "bool", "{", "select", "{", "case",...
// Wait implements Assertion.
[ "Wait", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L435-L445
150,542
tideland/golib
audit/asserts.go
Retry
func (a *assertion) Retry(rf func() bool, retries int, pause time.Duration, msgs ...string) bool { start := time.Now() for r := 0; r < retries; r++ { if rf() { return true } time.Sleep(pause) } needed := time.Now().Sub(start) info := fmt.Sprintf("timeout after %v and %d retries", needed, retries) return ...
go
func (a *assertion) Retry(rf func() bool, retries int, pause time.Duration, msgs ...string) bool { start := time.Now() for r := 0; r < retries; r++ { if rf() { return true } time.Sleep(pause) } needed := time.Now().Sub(start) info := fmt.Sprintf("timeout after %v and %d retries", needed, retries) return ...
[ "func", "(", "a", "*", "assertion", ")", "Retry", "(", "rf", "func", "(", ")", "bool", ",", "retries", "int", ",", "pause", "time", ".", "Duration", ",", "msgs", "...", "string", ")", "bool", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n"...
// Retry implements Assertion.
[ "Retry", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L459-L470
150,543
tideland/golib
audit/asserts.go
Fail
func (a *assertion) Fail(msgs ...string) bool { return a.failer.Fail(Fail, nil, nil, msgs...) }
go
func (a *assertion) Fail(msgs ...string) bool { return a.failer.Fail(Fail, nil, nil, msgs...) }
[ "func", "(", "a", "*", "assertion", ")", "Fail", "(", "msgs", "...", "string", ")", "bool", "{", "return", "a", ".", "failer", ".", "Fail", "(", "Fail", ",", "nil", ",", "nil", ",", "msgs", "...", ")", "\n", "}" ]
// Fail implements Assertion.
[ "Fail", "implements", "Assertion", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L473-L475
150,544
tideland/golib
audit/asserts.go
obexString
func obexString(test Test, obtained, expected interface{}) string { switch test { case True, False, Nil, NotNil, Empty, NotEmpty: return fmt.Sprintf("'%v'", obtained) case Implementor, Assignable, Unassignable: return fmt.Sprintf("'%v' <> '%v'", ValueDescription(obtained), ValueDescription(expected)) case Range...
go
func obexString(test Test, obtained, expected interface{}) string { switch test { case True, False, Nil, NotNil, Empty, NotEmpty: return fmt.Sprintf("'%v'", obtained) case Implementor, Assignable, Unassignable: return fmt.Sprintf("'%v' <> '%v'", ValueDescription(obtained), ValueDescription(expected)) case Range...
[ "func", "obexString", "(", "test", "Test", ",", "obtained", ",", "expected", "interface", "{", "}", ")", "string", "{", "switch", "test", "{", "case", "True", ",", "False", ",", "Nil", ",", "NotNil", ",", "Empty", ",", "NotEmpty", ":", "return", "fmt",...
// obexString constructs a descriptive sting matching // to test, obtained, and expected value.
[ "obexString", "constructs", "a", "descriptive", "sting", "matching", "to", "test", "obtained", "and", "expected", "value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L494-L508
150,545
tideland/golib
audit/asserts.go
failString
func failString(test Test, obex string, msgs ...string) string { var out string if test == Fail { out = fmt.Sprintf("assert failed: %s", obex) } else { out = fmt.Sprintf("assert '%s' failed: %s", test, obex) } jmsgs := strings.Join(msgs, " ") if len(jmsgs) > 0 { out += " (" + jmsgs + ")" } return out }
go
func failString(test Test, obex string, msgs ...string) string { var out string if test == Fail { out = fmt.Sprintf("assert failed: %s", obex) } else { out = fmt.Sprintf("assert '%s' failed: %s", test, obex) } jmsgs := strings.Join(msgs, " ") if len(jmsgs) > 0 { out += " (" + jmsgs + ")" } return out }
[ "func", "failString", "(", "test", "Test", ",", "obex", "string", ",", "msgs", "...", "string", ")", "string", "{", "var", "out", "string", "\n", "if", "test", "==", "Fail", "{", "out", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "obex", ")",...
// failString constructs a fail string for panics or // validition errors.
[ "failString", "constructs", "a", "fail", "string", "for", "panics", "or", "validition", "errors", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/asserts.go#L512-L524
150,546
tideland/golib
feed/rss/rss.go
Validate
func (r *RSS) Validate() error { if r.Version != Version { return errors.New(ErrValidation, errorMessages, "invalid RSS document version: %q", r.Version) } return r.Channel.Validate() }
go
func (r *RSS) Validate() error { if r.Version != Version { return errors.New(ErrValidation, errorMessages, "invalid RSS document version: %q", r.Version) } return r.Channel.Validate() }
[ "func", "(", "r", "*", "RSS", ")", "Validate", "(", ")", "error", "{", "if", "r", ".", "Version", "!=", "Version", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ",", "r", ".", "Version", ")", "\n"...
// Validate checks if the RSS document is valid.
[ "Validate", "checks", "if", "the", "RSS", "document", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L54-L59
150,547
tideland/golib
feed/rss/rss.go
Validate
func (c Channel) Validate() error { if c.Title == "" { return errors.New(ErrValidation, errorMessages, "channel title must not be empty") } if c.Description == "" { return errors.New(ErrValidation, errorMessages, "channel description must not be empty") } if c.Link == "" { return errors.New(ErrValidation, er...
go
func (c Channel) Validate() error { if c.Title == "" { return errors.New(ErrValidation, errorMessages, "channel title must not be empty") } if c.Description == "" { return errors.New(ErrValidation, errorMessages, "channel description must not be empty") } if c.Link == "" { return errors.New(ErrValidation, er...
[ "func", "(", "c", "Channel", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "Title", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "c", "....
// Validate checks if the cannel is valid.
[ "Validate", "checks", "if", "the", "cannel", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L86-L149
150,548
tideland/golib
feed/rss/rss.go
Validate
func (c *Category) Validate() error { if c.Category == "" { return errors.New(ErrValidation, errorMessages, "channel category must not be empty") } return nil }
go
func (c *Category) Validate() error { if c.Category == "" { return errors.New(ErrValidation, errorMessages, "channel category must not be empty") } return nil }
[ "func", "(", "c", "*", "Category", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "Category", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "retur...
// Validate checks if the category is valid.
[ "Validate", "checks", "if", "the", "category", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L158-L163
150,549
tideland/golib
feed/rss/rss.go
Validate
func (c *Cloud) Validate() error { if c.Domain == "" { return errors.New(ErrValidation, errorMessages, "cloud domain must not be empty") } if c.Path == "" || c.Path[0] != '/' { return errors.New(ErrValidation, errorMessages, "cloud path %q must not be empty and has to start with a slash", c.Path) } if c.Port <...
go
func (c *Cloud) Validate() error { if c.Domain == "" { return errors.New(ErrValidation, errorMessages, "cloud domain must not be empty") } if c.Path == "" || c.Path[0] != '/' { return errors.New(ErrValidation, errorMessages, "cloud path %q must not be empty and has to start with a slash", c.Path) } if c.Port <...
[ "func", "(", "c", "*", "Cloud", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "Domain", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "c"...
// Validate checks if the cloud is valid.
[ "Validate", "checks", "if", "the", "cloud", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L176-L187
150,550
tideland/golib
feed/rss/rss.go
Validate
func (i *Image) Validate() error { if _, err := url.Parse(i.Link); err != nil { return errors.New(ErrValidation, errorMessages, "image link is not parsable", i.Link) } if i.Title == "" { return errors.New(ErrValidation, errorMessages, "image title must not be empty") } if _, err := url.Parse(i.URL); err != nil...
go
func (i *Image) Validate() error { if _, err := url.Parse(i.Link); err != nil { return errors.New(ErrValidation, errorMessages, "image link is not parsable", i.Link) } if i.Title == "" { return errors.New(ErrValidation, errorMessages, "image title must not be empty") } if _, err := url.Parse(i.URL); err != nil...
[ "func", "(", "i", "*", "Image", ")", "Validate", "(", ")", "error", "{", "if", "_", ",", "err", ":=", "url", ".", "Parse", "(", "i", ".", "Link", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "err...
// Validate checks if the image is valid.
[ "Validate", "checks", "if", "the", "image", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L200-L217
150,551
tideland/golib
feed/rss/rss.go
Validate
func (s *SkipDays) Validate() error { skipDays := map[string]bool{ "Monday": true, "Tuesday": true, "Wednesday": true, "Thursday": true, "Friday": true, "Saturday": true, "Sunday": true, } for _, day := range s.Days { if !skipDays[day] { return errors.New(ErrValidation, errorMessages,...
go
func (s *SkipDays) Validate() error { skipDays := map[string]bool{ "Monday": true, "Tuesday": true, "Wednesday": true, "Thursday": true, "Friday": true, "Saturday": true, "Sunday": true, } for _, day := range s.Days { if !skipDays[day] { return errors.New(ErrValidation, errorMessages,...
[ "func", "(", "s", "*", "SkipDays", ")", "Validate", "(", ")", "error", "{", "skipDays", ":=", "map", "[", "string", "]", "bool", "{", "\"", "\"", ":", "true", ",", "\"", "\"", ":", "true", ",", "\"", "\"", ":", "true", ",", "\"", "\"", ":", "...
// Validate checks if the skip days are valid.
[ "Validate", "checks", "if", "the", "skip", "days", "are", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L225-L241
150,552
tideland/golib
feed/rss/rss.go
Validate
func (s *SkipHours) Validate() error { for _, hour := range s.Hours { if hour < 0 || hour > 23 { return errors.New(ErrValidation, errorMessages, "skip hour %d is out of range from 0 to 23", hour) } } return nil }
go
func (s *SkipHours) Validate() error { for _, hour := range s.Hours { if hour < 0 || hour > 23 { return errors.New(ErrValidation, errorMessages, "skip hour %d is out of range from 0 to 23", hour) } } return nil }
[ "func", "(", "s", "*", "SkipHours", ")", "Validate", "(", ")", "error", "{", "for", "_", ",", "hour", ":=", "range", "s", ".", "Hours", "{", "if", "hour", "<", "0", "||", "hour", ">", "23", "{", "return", "errors", ".", "New", "(", "ErrValidation...
// Validate checks if the skip hours are valid.
[ "Validate", "checks", "if", "the", "skip", "hours", "are", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L249-L256
150,553
tideland/golib
feed/rss/rss.go
Validate
func (t *TextInput) Validate() error { if t.Description == "" { return errors.New(ErrValidation, errorMessages, "text input description must not be empty") } if _, err := url.Parse(t.Link); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "text input link") } if t.Name == "" { return error...
go
func (t *TextInput) Validate() error { if t.Description == "" { return errors.New(ErrValidation, errorMessages, "text input description must not be empty") } if _, err := url.Parse(t.Link); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "text input link") } if t.Name == "" { return error...
[ "func", "(", "t", "*", "TextInput", ")", "Validate", "(", ")", "error", "{", "if", "t", ".", "Description", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "i...
// Validate checks if the text input is valid.
[ "Validate", "checks", "if", "the", "text", "input", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L268-L282
150,554
tideland/golib
feed/rss/rss.go
Validate
func (i *Item) Validate() error { if i.Title == "" { if i.Description == "" { return errors.New(ErrValidation, errorMessages, "item title or description must not be empty") } } if i.Comments != "" { if _, err := url.Parse(i.Comments); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "i...
go
func (i *Item) Validate() error { if i.Title == "" { if i.Description == "" { return errors.New(ErrValidation, errorMessages, "item title or description must not be empty") } } if i.Comments != "" { if _, err := url.Parse(i.Comments); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "i...
[ "func", "(", "i", "*", "Item", ")", "Validate", "(", ")", "error", "{", "if", "i", ".", "Title", "==", "\"", "\"", "{", "if", "i", ".", "Description", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages"...
// Validate checks if the item is valid.
[ "Validate", "checks", "if", "the", "item", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L301-L338
150,555
tideland/golib
feed/rss/rss.go
Validate
func (e *Enclosure) Validate() error { if e.Length < 1 { return errors.New(ErrValidation, errorMessages, "item enclosure length %d is too small", e.Length) } if e.Type == "" { return errors.New(ErrValidation, errorMessages, "item enclosure type must not be empty") } if _, err := url.Parse(e.URL); err != nil { ...
go
func (e *Enclosure) Validate() error { if e.Length < 1 { return errors.New(ErrValidation, errorMessages, "item enclosure length %d is too small", e.Length) } if e.Type == "" { return errors.New(ErrValidation, errorMessages, "item enclosure type must not be empty") } if _, err := url.Parse(e.URL); err != nil { ...
[ "func", "(", "e", "*", "Enclosure", ")", "Validate", "(", ")", "error", "{", "if", "e", ".", "Length", "<", "1", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ",", "e", ".", "Length", ")", "\n", ...
// Validate checks if the enclosure is valid.
[ "Validate", "checks", "if", "the", "enclosure", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L348-L359
150,556
tideland/golib
feed/rss/rss.go
Validate
func (g *GUID) Validate() error { if g.IsPermaLink { if _, err := url.Parse(g.GUID); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "item GUID") } } return nil }
go
func (g *GUID) Validate() error { if g.IsPermaLink { if _, err := url.Parse(g.GUID); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "item GUID") } } return nil }
[ "func", "(", "g", "*", "GUID", ")", "Validate", "(", ")", "error", "{", "if", "g", ".", "IsPermaLink", "{", "if", "_", ",", "err", ":=", "url", ".", "Parse", "(", "g", ".", "GUID", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "...
// Validate checks if the GUID is valid.
[ "Validate", "checks", "if", "the", "GUID", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L368-L375
150,557
tideland/golib
feed/rss/rss.go
Validate
func (s *Source) Validate() error { if s.Source == "" { return errors.New(ErrValidation, errorMessages, "item source must not be empty") } if _, err := url.Parse(s.URL); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "item source URL") } return nil }
go
func (s *Source) Validate() error { if s.Source == "" { return errors.New(ErrValidation, errorMessages, "item source must not be empty") } if _, err := url.Parse(s.URL); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "item source URL") } return nil }
[ "func", "(", "s", "*", "Source", ")", "Validate", "(", ")", "error", "{", "if", "s", ".", "Source", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "_...
// Validate checks if the source is valid.
[ "Validate", "checks", "if", "the", "source", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L384-L392
150,558
tideland/golib
feed/rss/rss.go
Encode
func Encode(w io.Writer, rss *RSS) error { enc := xml.NewEncoder(w) if _, err := w.Write([]byte(xml.Header)); err != nil { return err } return enc.Encode(rss) }
go
func Encode(w io.Writer, rss *RSS) error { enc := xml.NewEncoder(w) if _, err := w.Write([]byte(xml.Header)); err != nil { return err } return enc.Encode(rss) }
[ "func", "Encode", "(", "w", "io", ".", "Writer", ",", "rss", "*", "RSS", ")", "error", "{", "enc", ":=", "xml", ".", "NewEncoder", "(", "w", ")", "\n", "if", "_", ",", "err", ":=", "w", ".", "Write", "(", "[", "]", "byte", "(", "xml", ".", ...
// Encode writes the RSS document to the writer.
[ "Encode", "writes", "the", "RSS", "document", "to", "the", "writer", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L416-L422
150,559
tideland/golib
feed/rss/rss.go
Decode
func Decode(r io.Reader) (*RSS, error) { dec := xml.NewDecoder(r) dec.CharsetReader = utils.CharsetReader rss := &RSS{} if err := dec.Decode(rss); err != nil { return nil, err } return rss, nil }
go
func Decode(r io.Reader) (*RSS, error) { dec := xml.NewDecoder(r) dec.CharsetReader = utils.CharsetReader rss := &RSS{} if err := dec.Decode(rss); err != nil { return nil, err } return rss, nil }
[ "func", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "*", "RSS", ",", "error", ")", "{", "dec", ":=", "xml", ".", "NewDecoder", "(", "r", ")", "\n", "dec", ".", "CharsetReader", "=", "utils", ".", "CharsetReader", "\n", "rss", ":=", "&", "R...
// Decode reads the RSS document from the reader.
[ "Decode", "reads", "the", "RSS", "document", "from", "the", "reader", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L425-L433
150,560
tideland/golib
feed/rss/rss.go
Get
func Get(u *url.URL) (*RSS, error) { resp, err := http.Get(u.String()) if err != nil { return nil, err } defer resp.Body.Close() return Decode(resp.Body) }
go
func Get(u *url.URL) (*RSS, error) { resp, err := http.Get(u.String()) if err != nil { return nil, err } defer resp.Body.Close() return Decode(resp.Body) }
[ "func", "Get", "(", "u", "*", "url", ".", "URL", ")", "(", "*", "RSS", ",", "error", ")", "{", "resp", ",", "err", ":=", "http", ".", "Get", "(", "u", ".", "String", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// Get retrieves an RSS document from the given URL.
[ "Get", "retrieves", "an", "RSS", "document", "from", "the", "given", "URL", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/rss/rss.go#L436-L443
150,561
tideland/golib
redis/subscription.go
newSubscription
func newSubscription(db *Database) (*Subscription, error) { sub := &Subscription{ database: db, } err := sub.ensureProtocol() if err != nil { return nil, err } // Perform authentication and database selection. err = sub.resp.authenticate() if err != nil { sub.database.pool.kill(sub.resp) return nil, err...
go
func newSubscription(db *Database) (*Subscription, error) { sub := &Subscription{ database: db, } err := sub.ensureProtocol() if err != nil { return nil, err } // Perform authentication and database selection. err = sub.resp.authenticate() if err != nil { sub.database.pool.kill(sub.resp) return nil, err...
[ "func", "newSubscription", "(", "db", "*", "Database", ")", "(", "*", "Subscription", ",", "error", ")", "{", "sub", ":=", "&", "Subscription", "{", "database", ":", "db", ",", "}", "\n", "err", ":=", "sub", ".", "ensureProtocol", "(", ")", "\n", "if...
// newSubscription creates a new subscription.
[ "newSubscription", "creates", "a", "new", "subscription", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/subscription.go#L32-L47
150,562
tideland/golib
redis/subscription.go
subUnsub
func (sub *Subscription) subUnsub(cmd string, channels ...string) error { err := sub.ensureProtocol() if err != nil { return err } pattern := false args := []interface{}{} for _, channel := range channels { if containsPattern(channel) { pattern = true } args = append(args, channel) } if pattern { c...
go
func (sub *Subscription) subUnsub(cmd string, channels ...string) error { err := sub.ensureProtocol() if err != nil { return err } pattern := false args := []interface{}{} for _, channel := range channels { if containsPattern(channel) { pattern = true } args = append(args, channel) } if pattern { c...
[ "func", "(", "sub", "*", "Subscription", ")", "subUnsub", "(", "cmd", "string", ",", "channels", "...", "string", ")", "error", "{", "err", ":=", "sub", ".", "ensureProtocol", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}",...
// subUnsub is the generic subscription and unsubscription method.
[ "subUnsub", "is", "the", "generic", "subscription", "and", "unsubscription", "method", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/subscription.go#L60-L79
150,563
tideland/golib
redis/subscription.go
Pop
func (sub *Subscription) Pop() (*PublishedValue, error) { err := sub.ensureProtocol() if err != nil { return nil, err } result, err := sub.resp.receiveResultSet() if err != nil { return nil, err } // Analyse the result. kind, err := result.StringAt(0) if err != nil { return nil, err } switch { case st...
go
func (sub *Subscription) Pop() (*PublishedValue, error) { err := sub.ensureProtocol() if err != nil { return nil, err } result, err := sub.resp.receiveResultSet() if err != nil { return nil, err } // Analyse the result. kind, err := result.StringAt(0) if err != nil { return nil, err } switch { case st...
[ "func", "(", "sub", "*", "Subscription", ")", "Pop", "(", ")", "(", "*", "PublishedValue", ",", "error", ")", "{", "err", ":=", "sub", ".", "ensureProtocol", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "...
// Pop waits for a published value and returns it.
[ "Pop", "waits", "for", "a", "published", "value", "and", "returns", "it", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/subscription.go#L82-L128
150,564
tideland/golib
redis/subscription.go
Close
func (sub *Subscription) Close() error { err := sub.ensureProtocol() if err != nil { return err } err = sub.resp.sendCommand("punsubscribe") if err != nil { return err } for { pv, err := sub.Pop() if err != nil { return err } if pv.Kind == "punsubscribe" { break } } sub.database.pool.push(s...
go
func (sub *Subscription) Close() error { err := sub.ensureProtocol() if err != nil { return err } err = sub.resp.sendCommand("punsubscribe") if err != nil { return err } for { pv, err := sub.Pop() if err != nil { return err } if pv.Kind == "punsubscribe" { break } } sub.database.pool.push(s...
[ "func", "(", "sub", "*", "Subscription", ")", "Close", "(", ")", "error", "{", "err", ":=", "sub", ".", "ensureProtocol", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "sub", ".", "resp", ".", "sendC...
// Close ends the subscription.
[ "Close", "ends", "the", "subscription", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/subscription.go#L131-L151
150,565
tideland/golib
timex/retry.go
ShortAttempt
func ShortAttempt() RetryStrategy { return RetryStrategy{ Count: 10, Break: 50 * time.Millisecond, BreakIncrement: 0, Timeout: 5 * time.Second, } }
go
func ShortAttempt() RetryStrategy { return RetryStrategy{ Count: 10, Break: 50 * time.Millisecond, BreakIncrement: 0, Timeout: 5 * time.Second, } }
[ "func", "ShortAttempt", "(", ")", "RetryStrategy", "{", "return", "RetryStrategy", "{", "Count", ":", "10", ",", "Break", ":", "50", "*", "time", ".", "Millisecond", ",", "BreakIncrement", ":", "0", ",", "Timeout", ":", "5", "*", "time", ".", "Second", ...
// ShortAttempt returns a predefined short retry strategy.
[ "ShortAttempt", "returns", "a", "predefined", "short", "retry", "strategy", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/retry.go#L35-L42
150,566
tideland/golib
timex/retry.go
LongAttempt
func LongAttempt() RetryStrategy { return RetryStrategy{ Count: 100, Break: 10 * time.Millisecond, BreakIncrement: 25 * time.Millisecond, Timeout: 5 * time.Minute, } }
go
func LongAttempt() RetryStrategy { return RetryStrategy{ Count: 100, Break: 10 * time.Millisecond, BreakIncrement: 25 * time.Millisecond, Timeout: 5 * time.Minute, } }
[ "func", "LongAttempt", "(", ")", "RetryStrategy", "{", "return", "RetryStrategy", "{", "Count", ":", "100", ",", "Break", ":", "10", "*", "time", ".", "Millisecond", ",", "BreakIncrement", ":", "25", "*", "time", ".", "Millisecond", ",", "Timeout", ":", ...
// LongAttempt returns a predefined long retry strategy.
[ "LongAttempt", "returns", "a", "predefined", "long", "retry", "strategy", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/retry.go#L55-L62
150,567
tideland/golib
timex/retry.go
Retry
func Retry(f func() (bool, error), rs RetryStrategy) error { timeout := time.Now().Add(rs.Timeout) sleep := rs.Break for i := 0; i < rs.Count; i++ { done, err := f() if err != nil { return err } if done { return nil } if time.Now().After(timeout) { return errors.New(ErrRetriedTooLong, errorMessa...
go
func Retry(f func() (bool, error), rs RetryStrategy) error { timeout := time.Now().Add(rs.Timeout) sleep := rs.Break for i := 0; i < rs.Count; i++ { done, err := f() if err != nil { return err } if done { return nil } if time.Now().After(timeout) { return errors.New(ErrRetriedTooLong, errorMessa...
[ "func", "Retry", "(", "f", "func", "(", ")", "(", "bool", ",", "error", ")", ",", "rs", "RetryStrategy", ")", "error", "{", "timeout", ":=", "time", ".", "Now", "(", ")", ".", "Add", "(", "rs", ".", "Timeout", ")", "\n", "sleep", ":=", "rs", "....
// Retry executes the passed function until it returns true or an error. // These retries are restricted by the retry strategy.
[ "Retry", "executes", "the", "passed", "function", "until", "it", "returns", "true", "or", "an", "error", ".", "These", "retries", "are", "restricted", "by", "the", "retry", "strategy", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/retry.go#L66-L84
150,568
tideland/golib
etc/etc.go
Value
func (v *value) Value() (string, error) { sv, err := v.changer.Value() if err != nil { return "", errors.New(ErrInvalidPath, errorMessages, fullPathToString(v.path)) } return sv, nil }
go
func (v *value) Value() (string, error) { sv, err := v.changer.Value() if err != nil { return "", errors.New(ErrInvalidPath, errorMessages, fullPathToString(v.path)) } return sv, nil }
[ "func", "(", "v", "*", "value", ")", "Value", "(", ")", "(", "string", ",", "error", ")", "{", "sv", ",", "err", ":=", "v", ".", "changer", ".", "Value", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".",...
// Value retrieves the value or an error. It implements // the Valuer interface.
[ "Value", "retrieves", "the", "value", "or", "an", "error", ".", "It", "implements", "the", "Valuer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L55-L61
150,569
tideland/golib
etc/etc.go
Read
func Read(source io.Reader) (Etc, error) { builder := sml.NewKeyStringValueTreeBuilder() err := sml.ReadSML(source, builder) if err != nil { return nil, errors.Annotate(err, ErrIllegalSourceFormat, errorMessages) } values, err := builder.Tree() if err != nil { return nil, errors.Annotate(err, ErrIllegalSource...
go
func Read(source io.Reader) (Etc, error) { builder := sml.NewKeyStringValueTreeBuilder() err := sml.ReadSML(source, builder) if err != nil { return nil, errors.Annotate(err, ErrIllegalSourceFormat, errorMessages) } values, err := builder.Tree() if err != nil { return nil, errors.Annotate(err, ErrIllegalSource...
[ "func", "Read", "(", "source", "io", ".", "Reader", ")", "(", "Etc", ",", "error", ")", "{", "builder", ":=", "sml", ".", "NewKeyStringValueTreeBuilder", "(", ")", "\n", "err", ":=", "sml", ".", "ReadSML", "(", "source", ",", "builder", ")", "\n", "i...
// Read reads the SML source of the configuration from a // reader, parses it, and returns the etc instance.
[ "Read", "reads", "the", "SML", "source", "of", "the", "configuration", "from", "a", "reader", "parses", "it", "and", "returns", "the", "etc", "instance", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L139-L159
150,570
tideland/golib
etc/etc.go
ReadFile
func ReadFile(filename string) (Etc, error) { source, err := ioutil.ReadFile(filename) if err != nil { return nil, errors.Annotate(err, ErrCannotReadFile, errorMessages, filename) } return ReadString(string(source)) }
go
func ReadFile(filename string) (Etc, error) { source, err := ioutil.ReadFile(filename) if err != nil { return nil, errors.Annotate(err, ErrCannotReadFile, errorMessages, filename) } return ReadString(string(source)) }
[ "func", "ReadFile", "(", "filename", "string", ")", "(", "Etc", ",", "error", ")", "{", "source", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate",...
// ReadFile reads the SML source of a configuration file, // parses it, and returns the etc instance.
[ "ReadFile", "reads", "the", "SML", "source", "of", "a", "configuration", "file", "parses", "it", "and", "returns", "the", "etc", "instance", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L169-L175
150,571
tideland/golib
etc/etc.go
HasPath
func (e *etc) HasPath(path string) bool { fullPath := makeFullPath(path) changer := e.values.At(fullPath...) return changer.Error() == nil }
go
func (e *etc) HasPath(path string) bool { fullPath := makeFullPath(path) changer := e.values.At(fullPath...) return changer.Error() == nil }
[ "func", "(", "e", "*", "etc", ")", "HasPath", "(", "path", "string", ")", "bool", "{", "fullPath", ":=", "makeFullPath", "(", "path", ")", "\n", "changer", ":=", "e", ".", "values", ".", "At", "(", "fullPath", "...", ")", "\n", "return", "changer", ...
// HasPath implements the Etc interface.
[ "HasPath", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L178-L182
150,572
tideland/golib
etc/etc.go
Do
func (e *etc) Do(path string, f func(p string) error) error { fullPath := makeFullPath(path) changer := e.values.At(fullPath...) if changer.Error() != nil { return changer.Error() } kvs, err := changer.List() if err != nil { return err } for _, kv := range kvs { p := pathToString(append(fullPath, kv.Key))...
go
func (e *etc) Do(path string, f func(p string) error) error { fullPath := makeFullPath(path) changer := e.values.At(fullPath...) if changer.Error() != nil { return changer.Error() } kvs, err := changer.List() if err != nil { return err } for _, kv := range kvs { p := pathToString(append(fullPath, kv.Key))...
[ "func", "(", "e", "*", "etc", ")", "Do", "(", "path", "string", ",", "f", "func", "(", "p", "string", ")", "error", ")", "error", "{", "fullPath", ":=", "makeFullPath", "(", "path", ")", "\n", "changer", ":=", "e", ".", "values", ".", "At", "(", ...
// Do implements the Etc interface.
[ "Do", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L185-L203
150,573
tideland/golib
etc/etc.go
ValueAsString
func (e *etc) ValueAsString(path, dv string) string { value := e.valueAt(path) return defaulter.AsString(value, dv) }
go
func (e *etc) ValueAsString(path, dv string) string { value := e.valueAt(path) return defaulter.AsString(value, dv) }
[ "func", "(", "e", "*", "etc", ")", "ValueAsString", "(", "path", ",", "dv", "string", ")", "string", "{", "value", ":=", "e", ".", "valueAt", "(", "path", ")", "\n", "return", "defaulter", ".", "AsString", "(", "value", ",", "dv", ")", "\n", "}" ]
// ValueAsString implements the Etc interface.
[ "ValueAsString", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L206-L209
150,574
tideland/golib
etc/etc.go
ValueAsBool
func (e *etc) ValueAsBool(path string, dv bool) bool { value := e.valueAt(path) return defaulter.AsBool(value, dv) }
go
func (e *etc) ValueAsBool(path string, dv bool) bool { value := e.valueAt(path) return defaulter.AsBool(value, dv) }
[ "func", "(", "e", "*", "etc", ")", "ValueAsBool", "(", "path", "string", ",", "dv", "bool", ")", "bool", "{", "value", ":=", "e", ".", "valueAt", "(", "path", ")", "\n", "return", "defaulter", ".", "AsBool", "(", "value", ",", "dv", ")", "\n", "}...
// ValueAsBool implements the Etc interface.
[ "ValueAsBool", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L212-L215
150,575
tideland/golib
etc/etc.go
ValueAsInt
func (e *etc) ValueAsInt(path string, dv int) int { value := e.valueAt(path) return defaulter.AsInt(value, dv) }
go
func (e *etc) ValueAsInt(path string, dv int) int { value := e.valueAt(path) return defaulter.AsInt(value, dv) }
[ "func", "(", "e", "*", "etc", ")", "ValueAsInt", "(", "path", "string", ",", "dv", "int", ")", "int", "{", "value", ":=", "e", ".", "valueAt", "(", "path", ")", "\n", "return", "defaulter", ".", "AsInt", "(", "value", ",", "dv", ")", "\n", "}" ]
// ValueAsInt implements the Etc interface.
[ "ValueAsInt", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L218-L221
150,576
tideland/golib
etc/etc.go
ValueAsFloat64
func (e *etc) ValueAsFloat64(path string, dv float64) float64 { value := e.valueAt(path) return defaulter.AsFloat64(value, dv) }
go
func (e *etc) ValueAsFloat64(path string, dv float64) float64 { value := e.valueAt(path) return defaulter.AsFloat64(value, dv) }
[ "func", "(", "e", "*", "etc", ")", "ValueAsFloat64", "(", "path", "string", ",", "dv", "float64", ")", "float64", "{", "value", ":=", "e", ".", "valueAt", "(", "path", ")", "\n", "return", "defaulter", ".", "AsFloat64", "(", "value", ",", "dv", ")", ...
// ValueAsFloat64 implements the Etc interface.
[ "ValueAsFloat64", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L224-L227
150,577
tideland/golib
etc/etc.go
ValueAsTime
func (e *etc) ValueAsTime(path, format string, dv time.Time) time.Time { value := e.valueAt(path) return defaulter.AsTime(value, format, dv) }
go
func (e *etc) ValueAsTime(path, format string, dv time.Time) time.Time { value := e.valueAt(path) return defaulter.AsTime(value, format, dv) }
[ "func", "(", "e", "*", "etc", ")", "ValueAsTime", "(", "path", ",", "format", "string", ",", "dv", "time", ".", "Time", ")", "time", ".", "Time", "{", "value", ":=", "e", ".", "valueAt", "(", "path", ")", "\n", "return", "defaulter", ".", "AsTime",...
// ValueAsTime implements the Etc interface.
[ "ValueAsTime", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L230-L233
150,578
tideland/golib
etc/etc.go
ValueAsDuration
func (e *etc) ValueAsDuration(path string, dv time.Duration) time.Duration { value := e.valueAt(path) return defaulter.AsDuration(value, dv) }
go
func (e *etc) ValueAsDuration(path string, dv time.Duration) time.Duration { value := e.valueAt(path) return defaulter.AsDuration(value, dv) }
[ "func", "(", "e", "*", "etc", ")", "ValueAsDuration", "(", "path", "string", ",", "dv", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "value", ":=", "e", ".", "valueAt", "(", "path", ")", "\n", "return", "defaulter", ".", "AsDuration", ...
// ValueAsDuration implements the Etc interface.
[ "ValueAsDuration", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L236-L239
150,579
tideland/golib
etc/etc.go
Split
func (e *etc) Split(path string) (Etc, error) { if !e.HasPath(path) { // Path not found, return empty configuration. return ReadString("{etc}") } fullPath := makeFullPath(path) values, err := e.values.CopyAt(fullPath...) if err != nil { return nil, errors.Annotate(err, ErrCannotSplit, errorMessages) } valu...
go
func (e *etc) Split(path string) (Etc, error) { if !e.HasPath(path) { // Path not found, return empty configuration. return ReadString("{etc}") } fullPath := makeFullPath(path) values, err := e.values.CopyAt(fullPath...) if err != nil { return nil, errors.Annotate(err, ErrCannotSplit, errorMessages) } valu...
[ "func", "(", "e", "*", "etc", ")", "Split", "(", "path", "string", ")", "(", "Etc", ",", "error", ")", "{", "if", "!", "e", ".", "HasPath", "(", "path", ")", "{", "// Path not found, return empty configuration.", "return", "ReadString", "(", "\"", "\"", ...
// Split implements the Etc interface.
[ "Split", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L242-L257
150,580
tideland/golib
etc/etc.go
Dump
func (e *etc) Dump() (Application, error) { appl := Application{} err := e.values.DoAllDeep(func(ks []string, v string) error { if len(ks) == 1 { // Continue on root element. return nil } path := strings.Join(ks[1:], "/") appl[path] = v return nil }) if err != nil { return nil, err } return appl...
go
func (e *etc) Dump() (Application, error) { appl := Application{} err := e.values.DoAllDeep(func(ks []string, v string) error { if len(ks) == 1 { // Continue on root element. return nil } path := strings.Join(ks[1:], "/") appl[path] = v return nil }) if err != nil { return nil, err } return appl...
[ "func", "(", "e", "*", "etc", ")", "Dump", "(", ")", "(", "Application", ",", "error", ")", "{", "appl", ":=", "Application", "{", "}", "\n", "err", ":=", "e", ".", "values", ".", "DoAllDeep", "(", "func", "(", "ks", "[", "]", "string", ",", "v...
// Dump implements the Etc interface.
[ "Dump", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L260-L275
150,581
tideland/golib
etc/etc.go
Apply
func (e *etc) Apply(appl Application) (Etc, error) { ec := &etc{ values: e.values.Copy(), } for path, value := range appl { fullPath := makeFullPath(path) _, err := ec.values.Create(fullPath...).SetValue(value) if err != nil { return nil, errors.Annotate(err, ErrCannotApply, errorMessages) } } return ...
go
func (e *etc) Apply(appl Application) (Etc, error) { ec := &etc{ values: e.values.Copy(), } for path, value := range appl { fullPath := makeFullPath(path) _, err := ec.values.Create(fullPath...).SetValue(value) if err != nil { return nil, errors.Annotate(err, ErrCannotApply, errorMessages) } } return ...
[ "func", "(", "e", "*", "etc", ")", "Apply", "(", "appl", "Application", ")", "(", "Etc", ",", "error", ")", "{", "ec", ":=", "&", "etc", "{", "values", ":", "e", ".", "values", ".", "Copy", "(", ")", ",", "}", "\n", "for", "path", ",", "value...
// Apply implements the Etc interface.
[ "Apply", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L278-L290
150,582
tideland/golib
etc/etc.go
Write
func (e *etc) Write(target io.Writer, prettyPrint bool) error { // Build the nodes tree. builder := sml.NewNodeBuilder() depth := 0 err := e.values.DoAllDeep(func(ks []string, v string) error { doDepth := len(ks) tag := ks[doDepth-1] for i := depth; i > doDepth; i-- { builder.EndTagNode() } switch { ...
go
func (e *etc) Write(target io.Writer, prettyPrint bool) error { // Build the nodes tree. builder := sml.NewNodeBuilder() depth := 0 err := e.values.DoAllDeep(func(ks []string, v string) error { doDepth := len(ks) tag := ks[doDepth-1] for i := depth; i > doDepth; i-- { builder.EndTagNode() } switch { ...
[ "func", "(", "e", "*", "etc", ")", "Write", "(", "target", "io", ".", "Writer", ",", "prettyPrint", "bool", ")", "error", "{", "// Build the nodes tree.", "builder", ":=", "sml", ".", "NewNodeBuilder", "(", ")", "\n", "depth", ":=", "0", "\n", "err", "...
// Write implements the Etc interface.
[ "Write", "implements", "the", "Etc", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L293-L334
150,583
tideland/golib
etc/etc.go
valueAt
func (e *etc) valueAt(path string) *value { fullPath := makeFullPath(path) changer := e.values.At(fullPath...) return &value{fullPath, changer} }
go
func (e *etc) valueAt(path string) *value { fullPath := makeFullPath(path) changer := e.values.At(fullPath...) return &value{fullPath, changer} }
[ "func", "(", "e", "*", "etc", ")", "valueAt", "(", "path", "string", ")", "*", "value", "{", "fullPath", ":=", "makeFullPath", "(", "path", ")", "\n", "changer", ":=", "e", ".", "values", ".", "At", "(", "fullPath", "...", ")", "\n", "return", "&",...
// valueAt retrieves and encapsulates the value // at a given path.
[ "valueAt", "retrieves", "and", "encapsulates", "the", "value", "at", "a", "given", "path", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L343-L347
150,584
tideland/golib
etc/etc.go
FromContext
func FromContext(ctx context.Context) (Etc, bool) { cfg, ok := ctx.Value(etcKey).(Etc) return cfg, ok }
go
func FromContext(ctx context.Context) (Etc, bool) { cfg, ok := ctx.Value(etcKey).(Etc) return cfg, ok }
[ "func", "FromContext", "(", "ctx", "context", ".", "Context", ")", "(", "Etc", ",", "bool", ")", "{", "cfg", ",", "ok", ":=", "ctx", ".", "Value", "(", "etcKey", ")", ".", "(", "Etc", ")", "\n", "return", "cfg", ",", "ok", "\n", "}" ]
// FromContext returns the configuration stored in ctx, if any.
[ "FromContext", "returns", "the", "configuration", "stored", "in", "ctx", "if", "any", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/etc/etc.go#L400-L403
150,585
tideland/golib
collections/ringbuffer.go
NewRingBuffer
func NewRingBuffer(size int) RingBuffer { rb := &ringBuffer{} rb.start = &valueLink{} rb.end = rb.start if size < 2 { size = 2 } for i := 0; i < size-1; i++ { link := &valueLink{} rb.end.next = link rb.end = link } rb.end.next = rb.start return rb }
go
func NewRingBuffer(size int) RingBuffer { rb := &ringBuffer{} rb.start = &valueLink{} rb.end = rb.start if size < 2 { size = 2 } for i := 0; i < size-1; i++ { link := &valueLink{} rb.end.next = link rb.end = link } rb.end.next = rb.start return rb }
[ "func", "NewRingBuffer", "(", "size", "int", ")", "RingBuffer", "{", "rb", ":=", "&", "ringBuffer", "{", "}", "\n", "rb", ".", "start", "=", "&", "valueLink", "{", "}", "\n", "rb", ".", "end", "=", "rb", ".", "start", "\n", "if", "size", "<", "2"...
// NewRingBuffer creates a new ring buffer.
[ "NewRingBuffer", "creates", "a", "new", "ring", "buffer", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/ringbuffer.go#L39-L53
150,586
tideland/golib
collections/ringbuffer.go
Push
func (rb *ringBuffer) Push(values ...interface{}) { for _, value := range values { if rb.end.next.used == false { rb.end.next.used = true rb.end.next.value = value rb.end = rb.end.next continue } link := &valueLink{ used: true, value: value, next: rb.start, } rb.end.next = link rb.en...
go
func (rb *ringBuffer) Push(values ...interface{}) { for _, value := range values { if rb.end.next.used == false { rb.end.next.used = true rb.end.next.value = value rb.end = rb.end.next continue } link := &valueLink{ used: true, value: value, next: rb.start, } rb.end.next = link rb.en...
[ "func", "(", "rb", "*", "ringBuffer", ")", "Push", "(", "values", "...", "interface", "{", "}", ")", "{", "for", "_", ",", "value", ":=", "range", "values", "{", "if", "rb", ".", "end", ".", "next", ".", "used", "==", "false", "{", "rb", ".", "...
// Push implements the RingBuffer interface.
[ "Push", "implements", "the", "RingBuffer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/ringbuffer.go#L56-L72
150,587
tideland/golib
collections/ringbuffer.go
Peek
func (rb *ringBuffer) Peek() (interface{}, bool) { if rb.start.used == false { return nil, false } return rb.start.value, true }
go
func (rb *ringBuffer) Peek() (interface{}, bool) { if rb.start.used == false { return nil, false } return rb.start.value, true }
[ "func", "(", "rb", "*", "ringBuffer", ")", "Peek", "(", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "if", "rb", ".", "start", ".", "used", "==", "false", "{", "return", "nil", ",", "false", "\n", "}", "\n", "return", "rb", ".", "sta...
// Peek implements the RingBuffer interface.
[ "Peek", "implements", "the", "RingBuffer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/ringbuffer.go#L75-L80
150,588
tideland/golib
collections/ringbuffer.go
Pop
func (rb *ringBuffer) Pop() (interface{}, bool) { if rb.start.used == false { return nil, false } value := rb.start.value rb.start.used = false rb.start.value = nil rb.start = rb.start.next return value, true }
go
func (rb *ringBuffer) Pop() (interface{}, bool) { if rb.start.used == false { return nil, false } value := rb.start.value rb.start.used = false rb.start.value = nil rb.start = rb.start.next return value, true }
[ "func", "(", "rb", "*", "ringBuffer", ")", "Pop", "(", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "if", "rb", ".", "start", ".", "used", "==", "false", "{", "return", "nil", ",", "false", "\n", "}", "\n", "value", ":=", "rb", ".", ...
// Pop implements the RingBuffer interface.
[ "Pop", "implements", "the", "RingBuffer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/ringbuffer.go#L83-L92
150,589
tideland/golib
collections/ringbuffer.go
Len
func (rb *ringBuffer) Len() int { l := 0 current := rb.start for current.used { l++ current = current.next if current == rb.start { break } } return l }
go
func (rb *ringBuffer) Len() int { l := 0 current := rb.start for current.used { l++ current = current.next if current == rb.start { break } } return l }
[ "func", "(", "rb", "*", "ringBuffer", ")", "Len", "(", ")", "int", "{", "l", ":=", "0", "\n", "current", ":=", "rb", ".", "start", "\n", "for", "current", ".", "used", "{", "l", "++", "\n", "current", "=", "current", ".", "next", "\n", "if", "c...
// Len implements the RingBuffer interface.
[ "Len", "implements", "the", "RingBuffer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/ringbuffer.go#L95-L106
150,590
tideland/golib
collections/ringbuffer.go
Cap
func (rb *ringBuffer) Cap() int { c := 1 current := rb.start for current.next != rb.start { c++ current = current.next } return c }
go
func (rb *ringBuffer) Cap() int { c := 1 current := rb.start for current.next != rb.start { c++ current = current.next } return c }
[ "func", "(", "rb", "*", "ringBuffer", ")", "Cap", "(", ")", "int", "{", "c", ":=", "1", "\n", "current", ":=", "rb", ".", "start", "\n", "for", "current", ".", "next", "!=", "rb", ".", "start", "{", "c", "++", "\n", "current", "=", "current", "...
// Cap implements the RingBuffer interface.
[ "Cap", "implements", "the", "RingBuffer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/ringbuffer.go#L109-L117
150,591
tideland/golib
mapreduce/mapreduce.go
MapReduce
func MapReduce(mr MapReducer) error { mapEmitChan := make(KeyValueChan) reduceEmitChan := make(KeyValueChan) go performReducing(mr, mapEmitChan, reduceEmitChan) go performMapping(mr, mapEmitChan) return mr.Consume(reduceEmitChan) }
go
func MapReduce(mr MapReducer) error { mapEmitChan := make(KeyValueChan) reduceEmitChan := make(KeyValueChan) go performReducing(mr, mapEmitChan, reduceEmitChan) go performMapping(mr, mapEmitChan) return mr.Consume(reduceEmitChan) }
[ "func", "MapReduce", "(", "mr", "MapReducer", ")", "error", "{", "mapEmitChan", ":=", "make", "(", "KeyValueChan", ")", "\n", "reduceEmitChan", ":=", "make", "(", "KeyValueChan", ")", "\n\n", "go", "performReducing", "(", "mr", ",", "mapEmitChan", ",", "redu...
// MapReduce applies a map and a reduce function to keys and values in parallel.
[ "MapReduce", "applies", "a", "map", "and", "a", "reduce", "function", "to", "keys", "and", "values", "in", "parallel", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/mapreduce/mapreduce.go#L63-L71
150,592
tideland/golib
mapreduce/mapreduce.go
newCloserChan
func newCloserChan(kvc KeyValueChan, size int) closerChan { signals := make(closerChan) go func() { ctr := 0 for { <-signals ctr++ if ctr == size { kvc.Close() close(signals) return } } }() return signals }
go
func newCloserChan(kvc KeyValueChan, size int) closerChan { signals := make(closerChan) go func() { ctr := 0 for { <-signals ctr++ if ctr == size { kvc.Close() close(signals) return } } }() return signals }
[ "func", "newCloserChan", "(", "kvc", "KeyValueChan", ",", "size", "int", ")", "closerChan", "{", "signals", ":=", "make", "(", "closerChan", ")", "\n", "go", "func", "(", ")", "{", "ctr", ":=", "0", "\n", "for", "{", "<-", "signals", "\n", "ctr", "++...
// closerChan closes given channel after a number of signals.
[ "closerChan", "closes", "given", "channel", "after", "a", "number", "of", "signals", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/mapreduce/mapreduce.go#L81-L96
150,593
tideland/golib
mapreduce/mapreduce.go
performReducing
func performReducing(mr MapReducer, mapEmitChan, reduceEmitChan KeyValueChan) { // Start a closer for the reduce emit chan. size := runtime.NumCPU() signals := newCloserChan(reduceEmitChan, size) // Start reduce goroutines. reduceChans := make([]KeyValueChan, size) for i := 0; i < size; i++ { reduceChans[i] = ...
go
func performReducing(mr MapReducer, mapEmitChan, reduceEmitChan KeyValueChan) { // Start a closer for the reduce emit chan. size := runtime.NumCPU() signals := newCloserChan(reduceEmitChan, size) // Start reduce goroutines. reduceChans := make([]KeyValueChan, size) for i := 0; i < size; i++ { reduceChans[i] = ...
[ "func", "performReducing", "(", "mr", "MapReducer", ",", "mapEmitChan", ",", "reduceEmitChan", "KeyValueChan", ")", "{", "// Start a closer for the reduce emit chan.", "size", ":=", "runtime", ".", "NumCPU", "(", ")", "\n", "signals", ":=", "newCloserChan", "(", "re...
// performReducing runs the reducing goroutines.
[ "performReducing", "runs", "the", "reducing", "goroutines", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/mapreduce/mapreduce.go#L99-L125
150,594
tideland/golib
mapreduce/mapreduce.go
performMapping
func performMapping(mr MapReducer, mapEmitChan KeyValueChan) { // Start a closer for the map emit chan. size := runtime.NumCPU() * 4 signals := newCloserChan(mapEmitChan, size) // Start map goroutines. mapChans := make([]KeyValueChan, size) for i := 0; i < size; i++ { mapChans[i] = make(KeyValueChan) go func...
go
func performMapping(mr MapReducer, mapEmitChan KeyValueChan) { // Start a closer for the map emit chan. size := runtime.NumCPU() * 4 signals := newCloserChan(mapEmitChan, size) // Start map goroutines. mapChans := make([]KeyValueChan, size) for i := 0; i < size; i++ { mapChans[i] = make(KeyValueChan) go func...
[ "func", "performMapping", "(", "mr", "MapReducer", ",", "mapEmitChan", "KeyValueChan", ")", "{", "// Start a closer for the map emit chan.", "size", ":=", "runtime", ".", "NumCPU", "(", ")", "*", "4", "\n", "signals", ":=", "newCloserChan", "(", "mapEmitChan", ","...
// Perform the mapping.
[ "Perform", "the", "mapping", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/mapreduce/mapreduce.go#L128-L156
150,595
tideland/golib
scroller/scroller.go
Lines
func Lines(l int) Option { return func(s *Scroller) error { if l < 0 { return errors.New(ErrNegativeLines, errorMessages, l) } s.lines = l return nil } }
go
func Lines(l int) Option { return func(s *Scroller) error { if l < 0 { return errors.New(ErrNegativeLines, errorMessages, l) } s.lines = l return nil } }
[ "func", "Lines", "(", "l", "int", ")", "Option", "{", "return", "func", "(", "s", "*", "Scroller", ")", "error", "{", "if", "l", "<", "0", "{", "return", "errors", ".", "New", "(", "ErrNegativeLines", ",", "errorMessages", ",", "l", ")", "\n", "}",...
// Lines sets the number of lines ro scroll initially.
[ "Lines", "sets", "the", "number", "of", "lines", "ro", "scroll", "initially", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L55-L63
150,596
tideland/golib
scroller/scroller.go
Filter
func Filter(ff FilterFunc) Option { return func(s *Scroller) error { s.filter = ff return nil } }
go
func Filter(ff FilterFunc) Option { return func(s *Scroller) error { s.filter = ff return nil } }
[ "func", "Filter", "(", "ff", "FilterFunc", ")", "Option", "{", "return", "func", "(", "s", "*", "Scroller", ")", "error", "{", "s", ".", "filter", "=", "ff", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Filter sets the filter function of the scroller.
[ "Filter", "sets", "the", "filter", "function", "of", "the", "scroller", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L66-L71
150,597
tideland/golib
scroller/scroller.go
BufferSize
func BufferSize(bs int) Option { return func(s *Scroller) error { s.bufferSize = bs return nil } }
go
func BufferSize(bs int) Option { return func(s *Scroller) error { s.bufferSize = bs return nil } }
[ "func", "BufferSize", "(", "bs", "int", ")", "Option", "{", "return", "func", "(", "s", "*", "Scroller", ")", "error", "{", "s", ".", "bufferSize", "=", "bs", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// BufferSize allows to set the initial size of the buffer // used for reading.
[ "BufferSize", "allows", "to", "set", "the", "initial", "size", "of", "the", "buffer", "used", "for", "reading", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L75-L80
150,598
tideland/golib
scroller/scroller.go
PollTime
func PollTime(pt time.Duration) Option { return func(s *Scroller) error { if pt == 0 { pt = defaultPollTime } s.pollTime = pt return nil } }
go
func PollTime(pt time.Duration) Option { return func(s *Scroller) error { if pt == 0 { pt = defaultPollTime } s.pollTime = pt return nil } }
[ "func", "PollTime", "(", "pt", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "s", "*", "Scroller", ")", "error", "{", "if", "pt", "==", "0", "{", "pt", "=", "defaultPollTime", "\n", "}", "\n", "s", ".", "pollTime", "=", "pt", ...
// PollTime defines the frequency the source is polled.
[ "PollTime", "defines", "the", "frequency", "the", "source", "is", "polled", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L83-L91
150,599
tideland/golib
scroller/scroller.go
NewScroller
func NewScroller(source io.ReadSeeker, target io.Writer, options ...Option) (*Scroller, error) { if source == nil { return nil, errors.New(ErrNoSource, errorMessages) } if target == nil { return nil, errors.New(ErrNoTarget, errorMessages) } s := &Scroller{ source: source, target: target, bufferSi...
go
func NewScroller(source io.ReadSeeker, target io.Writer, options ...Option) (*Scroller, error) { if source == nil { return nil, errors.New(ErrNoSource, errorMessages) } if target == nil { return nil, errors.New(ErrNoTarget, errorMessages) } s := &Scroller{ source: source, target: target, bufferSi...
[ "func", "NewScroller", "(", "source", "io", ".", "ReadSeeker", ",", "target", "io", ".", "Writer", ",", "options", "...", "Option", ")", "(", "*", "Scroller", ",", "error", ")", "{", "if", "source", "==", "nil", "{", "return", "nil", ",", "errors", "...
// NewScroller starts a Scroller for the given source and target. // The options can control the number of lines, a filter, the buffer // size and the poll time.
[ "NewScroller", "starts", "a", "Scroller", "for", "the", "given", "source", "and", "target", ".", "The", "options", "can", "control", "the", "number", "of", "lines", "a", "filter", "the", "buffer", "size", "and", "the", "poll", "time", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/scroller/scroller.go#L116-L138