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,200
tideland/golib
monitoring/monitoring.go
setBackend
func (m *monitoring) setBackend(mb Backend) { if m.b != nil { m.b.Stop() } m.b = mb }
go
func (m *monitoring) setBackend(mb Backend) { if m.b != nil { m.b.Stop() } m.b = mb }
[ "func", "(", "m", "*", "monitoring", ")", "setBackend", "(", "mb", "Backend", ")", "{", "if", "m", ".", "b", "!=", "nil", "{", "m", ".", "b", ".", "Stop", "(", ")", "\n", "}", "\n", "m", ".", "b", "=", "mb", "\n", "}" ]
// setBackend sets the current backend. If one // is already set it will be stopped.
[ "setBackend", "sets", "the", "current", "backend", ".", "If", "one", "is", "already", "set", "it", "will", "be", "stopped", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L225-L230
150,201
tideland/golib
monitoring/monitoring.go
SetBackend
func SetBackend(mb Backend) { monitor.Lock() defer monitor.Unlock() monitor.setBackend(mb) }
go
func SetBackend(mb Backend) { monitor.Lock() defer monitor.Unlock() monitor.setBackend(mb) }
[ "func", "SetBackend", "(", "mb", "Backend", ")", "{", "monitor", ".", "Lock", "(", ")", "\n", "defer", "monitor", ".", "Unlock", "(", ")", "\n", "monitor", ".", "setBackend", "(", "mb", ")", "\n", "}" ]
// SetBackend allows to switch the monitoring backend.
[ "SetBackend", "allows", "to", "switch", "the", "monitoring", "backend", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L236-L240
150,202
tideland/golib
monitoring/monitoring.go
BeginMeasuring
func BeginMeasuring(id string) Measuring { monitor.RLock() defer monitor.RUnlock() return monitor.backend().BeginMeasuring(id) }
go
func BeginMeasuring(id string) Measuring { monitor.RLock() defer monitor.RUnlock() return monitor.backend().BeginMeasuring(id) }
[ "func", "BeginMeasuring", "(", "id", "string", ")", "Measuring", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "BeginMeasuring", "(", "id", ")", "\n...
// BeginMeasuring starts a new measuring with a given id. // All measurings with the same id will be aggregated.
[ "BeginMeasuring", "starts", "a", "new", "measuring", "with", "a", "given", "id", ".", "All", "measurings", "with", "the", "same", "id", "will", "be", "aggregated", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L244-L248
150,203
tideland/golib
monitoring/monitoring.go
Measure
func Measure(id string, f func()) time.Duration { m := BeginMeasuring(id) f() return m.EndMeasuring() }
go
func Measure(id string, f func()) time.Duration { m := BeginMeasuring(id) f() return m.EndMeasuring() }
[ "func", "Measure", "(", "id", "string", ",", "f", "func", "(", ")", ")", "time", ".", "Duration", "{", "m", ":=", "BeginMeasuring", "(", "id", ")", "\n", "f", "(", ")", "\n", "return", "m", ".", "EndMeasuring", "(", ")", "\n", "}" ]
// Measure the execution of a function.
[ "Measure", "the", "execution", "of", "a", "function", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L251-L255
150,204
tideland/golib
monitoring/monitoring.go
ReadMeasuringPoint
func ReadMeasuringPoint(id string) (MeasuringPoint, error) { monitor.RLock() defer monitor.RUnlock() return monitor.backend().ReadMeasuringPoint(id) }
go
func ReadMeasuringPoint(id string) (MeasuringPoint, error) { monitor.RLock() defer monitor.RUnlock() return monitor.backend().ReadMeasuringPoint(id) }
[ "func", "ReadMeasuringPoint", "(", "id", "string", ")", "(", "MeasuringPoint", ",", "error", ")", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "Rea...
// ReadMeasuringPoint returns the measuring point for an id.
[ "ReadMeasuringPoint", "returns", "the", "measuring", "point", "for", "an", "id", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L258-L262
150,205
tideland/golib
monitoring/monitoring.go
MeasuringPointsDo
func MeasuringPointsDo(f func(MeasuringPoint)) error { monitor.RLock() defer monitor.RUnlock() return monitor.backend().MeasuringPointsDo(f) }
go
func MeasuringPointsDo(f func(MeasuringPoint)) error { monitor.RLock() defer monitor.RUnlock() return monitor.backend().MeasuringPointsDo(f) }
[ "func", "MeasuringPointsDo", "(", "f", "func", "(", "MeasuringPoint", ")", ")", "error", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "MeasuringPoint...
// MeasuringPointsDo performs the function f for // all measuring points.
[ "MeasuringPointsDo", "performs", "the", "function", "f", "for", "all", "measuring", "points", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L266-L270
150,206
tideland/golib
monitoring/monitoring.go
MeasuringPointsWrite
func MeasuringPointsWrite(w io.Writer, ff func(MeasuringPoint) bool) error { fmt.Fprint(w, etmTLine) fmt.Fprint(w, etmHeader) fmt.Fprint(w, etmTLine) if err := MeasuringPointsDo(func(mp MeasuringPoint) { if ff(mp) { fmt.Fprintf(w, etmFormat, mp.ID(), mp.Count(), mp.MinDuration(), mp.MaxDuration(), mp.AvgDurati...
go
func MeasuringPointsWrite(w io.Writer, ff func(MeasuringPoint) bool) error { fmt.Fprint(w, etmTLine) fmt.Fprint(w, etmHeader) fmt.Fprint(w, etmTLine) if err := MeasuringPointsDo(func(mp MeasuringPoint) { if ff(mp) { fmt.Fprintf(w, etmFormat, mp.ID(), mp.Count(), mp.MinDuration(), mp.MaxDuration(), mp.AvgDurati...
[ "func", "MeasuringPointsWrite", "(", "w", "io", ".", "Writer", ",", "ff", "func", "(", "MeasuringPoint", ")", "bool", ")", "error", "{", "fmt", ".", "Fprint", "(", "w", ",", "etmTLine", ")", "\n", "fmt", ".", "Fprint", "(", "w", ",", "etmHeader", ")"...
// MeasuringPointsWrite prints the measuring points for which // the passed function returns true to the passed writer.
[ "MeasuringPointsWrite", "prints", "the", "measuring", "points", "for", "which", "the", "passed", "function", "returns", "true", "to", "the", "passed", "writer", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L274-L287
150,207
tideland/golib
monitoring/monitoring.go
SetVariable
func SetVariable(id string, v int64) { monitor.RLock() defer monitor.RUnlock() monitor.backend().SetVariable(id, v) }
go
func SetVariable(id string, v int64) { monitor.RLock() defer monitor.RUnlock() monitor.backend().SetVariable(id, v) }
[ "func", "SetVariable", "(", "id", "string", ",", "v", "int64", ")", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "monitor", ".", "backend", "(", ")", ".", "SetVariable", "(", "id", ",", "v", ")",...
// SetVariable sets a value of a stay-set variable.
[ "SetVariable", "sets", "a", "value", "of", "a", "stay", "-", "set", "variable", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L296-L300
150,208
tideland/golib
monitoring/monitoring.go
IncrVariable
func IncrVariable(id string) { monitor.RLock() defer monitor.RUnlock() monitor.backend().IncrVariable(id) }
go
func IncrVariable(id string) { monitor.RLock() defer monitor.RUnlock() monitor.backend().IncrVariable(id) }
[ "func", "IncrVariable", "(", "id", "string", ")", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "monitor", ".", "backend", "(", ")", ".", "IncrVariable", "(", "id", ")", "\n", "}" ]
// IncrVariable increases a stay-set variable.
[ "IncrVariable", "increases", "a", "stay", "-", "set", "variable", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L303-L307
150,209
tideland/golib
monitoring/monitoring.go
DecrVariable
func DecrVariable(id string) { monitor.RLock() defer monitor.RUnlock() monitor.backend().DecrVariable(id) }
go
func DecrVariable(id string) { monitor.RLock() defer monitor.RUnlock() monitor.backend().DecrVariable(id) }
[ "func", "DecrVariable", "(", "id", "string", ")", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "monitor", ".", "backend", "(", ")", ".", "DecrVariable", "(", "id", ")", "\n", "}" ]
// DecrVariable decreases a stay-set variable.
[ "DecrVariable", "decreases", "a", "stay", "-", "set", "variable", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L310-L314
150,210
tideland/golib
monitoring/monitoring.go
ReadVariable
func ReadVariable(id string) (StaySetVariable, error) { monitor.RLock() defer monitor.RUnlock() return monitor.backend().ReadVariable(id) }
go
func ReadVariable(id string) (StaySetVariable, error) { monitor.RLock() defer monitor.RUnlock() return monitor.backend().ReadVariable(id) }
[ "func", "ReadVariable", "(", "id", "string", ")", "(", "StaySetVariable", ",", "error", ")", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "ReadVari...
// ReadVariable returns the stay-set variable for an id.
[ "ReadVariable", "returns", "the", "stay", "-", "set", "variable", "for", "an", "id", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L317-L321
150,211
tideland/golib
monitoring/monitoring.go
StaySetVariablesDo
func StaySetVariablesDo(f func(StaySetVariable)) error { monitor.RLock() defer monitor.RUnlock() return monitor.backend().StaySetVariablesDo(f) }
go
func StaySetVariablesDo(f func(StaySetVariable)) error { monitor.RLock() defer monitor.RUnlock() return monitor.backend().StaySetVariablesDo(f) }
[ "func", "StaySetVariablesDo", "(", "f", "func", "(", "StaySetVariable", ")", ")", "error", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "StaySetVaria...
// StaySetVariablesDo performs the function f for all // variables.
[ "StaySetVariablesDo", "performs", "the", "function", "f", "for", "all", "variables", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L325-L329
150,212
tideland/golib
monitoring/monitoring.go
StaySetVariablesWrite
func StaySetVariablesWrite(w io.Writer, ff func(StaySetVariable) bool) error { fmt.Fprint(w, ssvTLine) fmt.Fprint(w, ssvHeader) fmt.Fprint(w, ssvTLine) if err := StaySetVariablesDo(func(ssv StaySetVariable) { if ff(ssv) { fmt.Fprintf(w, ssvFormat, ssv.ID(), ssv.Count(), ssv.ActValue(), ssv.MinValue(), ssv.MaxV...
go
func StaySetVariablesWrite(w io.Writer, ff func(StaySetVariable) bool) error { fmt.Fprint(w, ssvTLine) fmt.Fprint(w, ssvHeader) fmt.Fprint(w, ssvTLine) if err := StaySetVariablesDo(func(ssv StaySetVariable) { if ff(ssv) { fmt.Fprintf(w, ssvFormat, ssv.ID(), ssv.Count(), ssv.ActValue(), ssv.MinValue(), ssv.MaxV...
[ "func", "StaySetVariablesWrite", "(", "w", "io", ".", "Writer", ",", "ff", "func", "(", "StaySetVariable", ")", "bool", ")", "error", "{", "fmt", ".", "Fprint", "(", "w", ",", "ssvTLine", ")", "\n", "fmt", ".", "Fprint", "(", "w", ",", "ssvHeader", "...
// StaySetVariablesWrite prints the stay-set variables for which // the passed function returns true to the passed writer.
[ "StaySetVariablesWrite", "prints", "the", "stay", "-", "set", "variables", "for", "which", "the", "passed", "function", "returns", "true", "to", "the", "passed", "writer", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L333-L346
150,213
tideland/golib
monitoring/monitoring.go
Register
func Register(id string, rf DynamicStatusRetriever) { monitor.RLock() defer monitor.RUnlock() monitor.backend().Register(id, rf) }
go
func Register(id string, rf DynamicStatusRetriever) { monitor.RLock() defer monitor.RUnlock() monitor.backend().Register(id, rf) }
[ "func", "Register", "(", "id", "string", ",", "rf", "DynamicStatusRetriever", ")", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "monitor", ".", "backend", "(", ")", ".", "Register", "(", "id", ",", ...
// Register registers a new dynamic status retriever function.
[ "Register", "registers", "a", "new", "dynamic", "status", "retriever", "function", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L355-L359
150,214
tideland/golib
monitoring/monitoring.go
ReadStatus
func ReadStatus(id string) (string, error) { monitor.RLock() defer monitor.RUnlock() return monitor.backend().ReadStatus(id) }
go
func ReadStatus(id string) (string, error) { monitor.RLock() defer monitor.RUnlock() return monitor.backend().ReadStatus(id) }
[ "func", "ReadStatus", "(", "id", "string", ")", "(", "string", ",", "error", ")", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "ReadStatus", "(",...
// ReadStatus returns the dynamic status for an id.
[ "ReadStatus", "returns", "the", "dynamic", "status", "for", "an", "id", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L362-L366
150,215
tideland/golib
monitoring/monitoring.go
DynamicStatusValuesDo
func DynamicStatusValuesDo(f func(DynamicStatusValue)) error { monitor.RLock() defer monitor.RUnlock() return monitor.backend().DynamicStatusValuesDo(f) }
go
func DynamicStatusValuesDo(f func(DynamicStatusValue)) error { monitor.RLock() defer monitor.RUnlock() return monitor.backend().DynamicStatusValuesDo(f) }
[ "func", "DynamicStatusValuesDo", "(", "f", "func", "(", "DynamicStatusValue", ")", ")", "error", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "Dynami...
// DynamicStatusValuesDo performs the function f for all // status values.
[ "DynamicStatusValuesDo", "performs", "the", "function", "f", "for", "all", "status", "values", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L370-L374
150,216
tideland/golib
monitoring/monitoring.go
DynamicStatusValuesWrite
func DynamicStatusValuesWrite(w io.Writer, ff func(DynamicStatusValue) bool) error { fmt.Fprint(w, dsrTLine) fmt.Fprint(w, dsrHeader) fmt.Fprint(w, dsrTLine) if err := DynamicStatusValuesDo(func(dsv DynamicStatusValue) { if ff(dsv) { fmt.Fprintf(w, dsrFormat, dsv.ID(), dsv.Value()) } }); err != nil { retu...
go
func DynamicStatusValuesWrite(w io.Writer, ff func(DynamicStatusValue) bool) error { fmt.Fprint(w, dsrTLine) fmt.Fprint(w, dsrHeader) fmt.Fprint(w, dsrTLine) if err := DynamicStatusValuesDo(func(dsv DynamicStatusValue) { if ff(dsv) { fmt.Fprintf(w, dsrFormat, dsv.ID(), dsv.Value()) } }); err != nil { retu...
[ "func", "DynamicStatusValuesWrite", "(", "w", "io", ".", "Writer", ",", "ff", "func", "(", "DynamicStatusValue", ")", "bool", ")", "error", "{", "fmt", ".", "Fprint", "(", "w", ",", "dsrTLine", ")", "\n", "fmt", ".", "Fprint", "(", "w", ",", "dsrHeader...
// DynamicStatusValuesWrite prints the status values for which // the passed function returns true to the passed writer.
[ "DynamicStatusValuesWrite", "prints", "the", "status", "values", "for", "which", "the", "passed", "function", "returns", "true", "to", "the", "passed", "writer", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L378-L391
150,217
tideland/golib
monitoring/monitoring.go
SetMeasuringsFilter
func SetMeasuringsFilter(f IDFilter) IDFilter { monitor.RLock() defer monitor.RUnlock() return monitor.backend().SetMeasuringsFilter(f) }
go
func SetMeasuringsFilter(f IDFilter) IDFilter { monitor.RLock() defer monitor.RUnlock() return monitor.backend().SetMeasuringsFilter(f) }
[ "func", "SetMeasuringsFilter", "(", "f", "IDFilter", ")", "IDFilter", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "SetMeasuringsFilter", "(", "f", "...
// SetMeasuringsFilter sets the new filter for measurings // and returns the current one.
[ "SetMeasuringsFilter", "sets", "the", "new", "filter", "for", "measurings", "and", "returns", "the", "current", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L400-L404
150,218
tideland/golib
monitoring/monitoring.go
SetVariablesFilter
func SetVariablesFilter(f IDFilter) IDFilter { monitor.RLock() defer monitor.RUnlock() return monitor.backend().SetVariablesFilter(f) }
go
func SetVariablesFilter(f IDFilter) IDFilter { monitor.RLock() defer monitor.RUnlock() return monitor.backend().SetVariablesFilter(f) }
[ "func", "SetVariablesFilter", "(", "f", "IDFilter", ")", "IDFilter", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "SetVariablesFilter", "(", "f", ")"...
// SetVariablesFilter sets the new filter for variables // and returns the current one.
[ "SetVariablesFilter", "sets", "the", "new", "filter", "for", "variables", "and", "returns", "the", "current", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L408-L412
150,219
tideland/golib
monitoring/monitoring.go
SetRetrieversFilter
func SetRetrieversFilter(f IDFilter) IDFilter { monitor.RLock() defer monitor.RUnlock() return monitor.backend().SetRetrieversFilter(f) }
go
func SetRetrieversFilter(f IDFilter) IDFilter { monitor.RLock() defer monitor.RUnlock() return monitor.backend().SetRetrieversFilter(f) }
[ "func", "SetRetrieversFilter", "(", "f", "IDFilter", ")", "IDFilter", "{", "monitor", ".", "RLock", "(", ")", "\n", "defer", "monitor", ".", "RUnlock", "(", ")", "\n", "return", "monitor", ".", "backend", "(", ")", ".", "SetRetrieversFilter", "(", "f", "...
// SetRetrieversFilter sets the new filter for status retrievers // and returns the current one.
[ "SetRetrieversFilter", "sets", "the", "new", "filter", "for", "status", "retrievers", "and", "returns", "the", "current", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L416-L420
150,220
tideland/golib
identifier/identifier.go
TypeAsIdentifierPart
func TypeAsIdentifierPart(i interface{}) string { var buf bytes.Buffer fullTypeName := reflect.TypeOf(i).String() lastDot := strings.LastIndex(fullTypeName, ".") typeName := fullTypeName[lastDot+1:] for i, r := range typeName { if unicode.IsUpper(r) { if i > 0 { buf.WriteRune('-') } } buf.WriteRune...
go
func TypeAsIdentifierPart(i interface{}) string { var buf bytes.Buffer fullTypeName := reflect.TypeOf(i).String() lastDot := strings.LastIndex(fullTypeName, ".") typeName := fullTypeName[lastDot+1:] for i, r := range typeName { if unicode.IsUpper(r) { if i > 0 { buf.WriteRune('-') } } buf.WriteRune...
[ "func", "TypeAsIdentifierPart", "(", "i", "interface", "{", "}", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "fullTypeName", ":=", "reflect", ".", "TypeOf", "(", "i", ")", ".", "String", "(", ")", "\n", "lastDot", ":=", "strings", "...
// TypeAsIdentifierPart transforms the name of the arguments type into // a part for identifiers. It's splitted at each uppercase char, // concatenated with dashes and transferred to lowercase.
[ "TypeAsIdentifierPart", "transforms", "the", "name", "of", "the", "arguments", "type", "into", "a", "part", "for", "identifiers", ".", "It", "s", "splitted", "at", "each", "uppercase", "char", "concatenated", "with", "dashes", "and", "transferred", "to", "lowerc...
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/identifier/identifier.go#L80-L94
150,221
tideland/golib
collections/sets.go
NewSet
func NewSet(vs ...interface{}) Set { s := &set{make(map[interface{}]struct{})} s.Add(vs...) return s }
go
func NewSet(vs ...interface{}) Set { s := &set{make(map[interface{}]struct{})} s.Add(vs...) return s }
[ "func", "NewSet", "(", "vs", "...", "interface", "{", "}", ")", "Set", "{", "s", ":=", "&", "set", "{", "make", "(", "map", "[", "interface", "{", "}", "]", "struct", "{", "}", ")", "}", "\n", "s", ".", "Add", "(", "vs", "...", ")", "\n", "...
// NewSet creates a set with the passed values // as initial content.
[ "NewSet", "creates", "a", "set", "with", "the", "passed", "values", "as", "initial", "content", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L31-L35
150,222
tideland/golib
collections/sets.go
Add
func (s *set) Add(vs ...interface{}) { for _, v := range vs { s.values[v] = struct{}{} } }
go
func (s *set) Add(vs ...interface{}) { for _, v := range vs { s.values[v] = struct{}{} } }
[ "func", "(", "s", "*", "set", ")", "Add", "(", "vs", "...", "interface", "{", "}", ")", "{", "for", "_", ",", "v", ":=", "range", "vs", "{", "s", ".", "values", "[", "v", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}" ]
// Add implements the Set interface.
[ "Add", "implements", "the", "Set", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L38-L42
150,223
tideland/golib
collections/sets.go
Remove
func (s *set) Remove(vs ...interface{}) { for _, v := range vs { delete(s.values, v) } }
go
func (s *set) Remove(vs ...interface{}) { for _, v := range vs { delete(s.values, v) } }
[ "func", "(", "s", "*", "set", ")", "Remove", "(", "vs", "...", "interface", "{", "}", ")", "{", "for", "_", ",", "v", ":=", "range", "vs", "{", "delete", "(", "s", ".", "values", ",", "v", ")", "\n", "}", "\n", "}" ]
// Remove implements the Set interface.
[ "Remove", "implements", "the", "Set", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L45-L49
150,224
tideland/golib
collections/sets.go
Contains
func (s *set) Contains(v interface{}) bool { _, ok := s.values[v] return ok }
go
func (s *set) Contains(v interface{}) bool { _, ok := s.values[v] return ok }
[ "func", "(", "s", "*", "set", ")", "Contains", "(", "v", "interface", "{", "}", ")", "bool", "{", "_", ",", "ok", ":=", "s", ".", "values", "[", "v", "]", "\n", "return", "ok", "\n", "}" ]
// Contains implements the Set interface.
[ "Contains", "implements", "the", "Set", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L52-L55
150,225
tideland/golib
collections/sets.go
All
func (s *set) All() []interface{} { all := []interface{}{} for v := range s.values { all = append(all, v) } return all }
go
func (s *set) All() []interface{} { all := []interface{}{} for v := range s.values { all = append(all, v) } return all }
[ "func", "(", "s", "*", "set", ")", "All", "(", ")", "[", "]", "interface", "{", "}", "{", "all", ":=", "[", "]", "interface", "{", "}", "{", "}", "\n", "for", "v", ":=", "range", "s", ".", "values", "{", "all", "=", "append", "(", "all", ",...
// All implements the Set interface.
[ "All", "implements", "the", "Set", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L58-L64
150,226
tideland/golib
collections/sets.go
DoAll
func (s *set) DoAll(f func(v interface{}) error) error { for v := range s.values { if err := f(v); err != nil { return errors.Annotate(err, ErrDoAll, errorMessages) } } return nil }
go
func (s *set) DoAll(f func(v interface{}) error) error { for v := range s.values { if err := f(v); err != nil { return errors.Annotate(err, ErrDoAll, errorMessages) } } return nil }
[ "func", "(", "s", "*", "set", ")", "DoAll", "(", "f", "func", "(", "v", "interface", "{", "}", ")", "error", ")", "error", "{", "for", "v", ":=", "range", "s", ".", "values", "{", "if", "err", ":=", "f", "(", "v", ")", ";", "err", "!=", "ni...
// DoAll implements the Set interface.
[ "DoAll", "implements", "the", "Set", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L82-L89
150,227
tideland/golib
collections/sets.go
NewStringSet
func NewStringSet(vs ...string) StringSet { s := &stringSet{make(map[string]struct{})} s.Add(vs...) return s }
go
func NewStringSet(vs ...string) StringSet { s := &stringSet{make(map[string]struct{})} s.Add(vs...) return s }
[ "func", "NewStringSet", "(", "vs", "...", "string", ")", "StringSet", "{", "s", ":=", "&", "stringSet", "{", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "}", "\n", "s", ".", "Add", "(", "vs", "...", ")", "\n", "return", "s", ...
// NewStringSet creates a string set with the passed values // as initial content.
[ "NewStringSet", "creates", "a", "string", "set", "with", "the", "passed", "values", "as", "initial", "content", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L118-L122
150,228
tideland/golib
collections/sets.go
Add
func (s *stringSet) Add(vs ...string) { for _, v := range vs { s.values[v] = struct{}{} } }
go
func (s *stringSet) Add(vs ...string) { for _, v := range vs { s.values[v] = struct{}{} } }
[ "func", "(", "s", "*", "stringSet", ")", "Add", "(", "vs", "...", "string", ")", "{", "for", "_", ",", "v", ":=", "range", "vs", "{", "s", ".", "values", "[", "v", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}" ]
// Add implements the StringSet interface.
[ "Add", "implements", "the", "StringSet", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L125-L129
150,229
tideland/golib
collections/sets.go
Remove
func (s *stringSet) Remove(vs ...string) { for _, v := range vs { delete(s.values, v) } }
go
func (s *stringSet) Remove(vs ...string) { for _, v := range vs { delete(s.values, v) } }
[ "func", "(", "s", "*", "stringSet", ")", "Remove", "(", "vs", "...", "string", ")", "{", "for", "_", ",", "v", ":=", "range", "vs", "{", "delete", "(", "s", ".", "values", ",", "v", ")", "\n", "}", "\n", "}" ]
// Remove implements the StringSet interface.
[ "Remove", "implements", "the", "StringSet", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L132-L136
150,230
tideland/golib
collections/sets.go
Contains
func (s *stringSet) Contains(v string) bool { _, ok := s.values[v] return ok }
go
func (s *stringSet) Contains(v string) bool { _, ok := s.values[v] return ok }
[ "func", "(", "s", "*", "stringSet", ")", "Contains", "(", "v", "string", ")", "bool", "{", "_", ",", "ok", ":=", "s", ".", "values", "[", "v", "]", "\n", "return", "ok", "\n", "}" ]
// Contains implements the StringSet interface.
[ "Contains", "implements", "the", "StringSet", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L139-L142
150,231
tideland/golib
collections/sets.go
All
func (s *stringSet) All() []string { all := []string{} for v := range s.values { all = append(all, v) } return all }
go
func (s *stringSet) All() []string { all := []string{} for v := range s.values { all = append(all, v) } return all }
[ "func", "(", "s", "*", "stringSet", ")", "All", "(", ")", "[", "]", "string", "{", "all", ":=", "[", "]", "string", "{", "}", "\n", "for", "v", ":=", "range", "s", ".", "values", "{", "all", "=", "append", "(", "all", ",", "v", ")", "\n", "...
// All implements the StringSet interface.
[ "All", "implements", "the", "StringSet", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L145-L151
150,232
tideland/golib
collections/sets.go
FindAll
func (s *stringSet) FindAll(f func(v string) (bool, error)) ([]string, error) { found := []string{} for v := range s.values { ok, err := f(v) if err != nil { return nil, errors.Annotate(err, ErrFindAll, errorMessages) } if ok { found = append(found, v) } } return found, nil }
go
func (s *stringSet) FindAll(f func(v string) (bool, error)) ([]string, error) { found := []string{} for v := range s.values { ok, err := f(v) if err != nil { return nil, errors.Annotate(err, ErrFindAll, errorMessages) } if ok { found = append(found, v) } } return found, nil }
[ "func", "(", "s", "*", "stringSet", ")", "FindAll", "(", "f", "func", "(", "v", "string", ")", "(", "bool", ",", "error", ")", ")", "(", "[", "]", "string", ",", "error", ")", "{", "found", ":=", "[", "]", "string", "{", "}", "\n", "for", "v"...
// FindAll implements the StringSet interface.
[ "FindAll", "implements", "the", "StringSet", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/sets.go#L154-L166
150,233
tideland/golib
audit/failer.go
Location
func (d *failureDetail) Location() (string, int, string) { return d.fileName, d.lineNumber, d.funcName }
go
func (d *failureDetail) Location() (string, int, string) { return d.fileName, d.lineNumber, d.funcName }
[ "func", "(", "d", "*", "failureDetail", ")", "Location", "(", ")", "(", "string", ",", "int", ",", "string", ")", "{", "return", "d", ".", "fileName", ",", "d", ".", "lineNumber", ",", "d", ".", "funcName", "\n", "}" ]
// Locations implements the FailureDetail interface.
[ "Locations", "implements", "the", "FailureDetail", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L80-L82
150,234
tideland/golib
audit/failer.go
HasErrors
func (f *validationFailer) HasErrors() bool { f.mux.Lock() defer f.mux.Unlock() return len(f.errs) > 0 }
go
func (f *validationFailer) HasErrors() bool { f.mux.Lock() defer f.mux.Unlock() return len(f.errs) > 0 }
[ "func", "(", "f", "*", "validationFailer", ")", "HasErrors", "(", ")", "bool", "{", "f", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mux", ".", "Unlock", "(", ")", "\n", "return", "len", "(", "f", ".", "errs", ")", ">", "0", ...
// HasErrors implements the Failures interface.
[ "HasErrors", "implements", "the", "Failures", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L157-L161
150,235
tideland/golib
audit/failer.go
Details
func (f *validationFailer) Details() []FailureDetail { f.mux.Lock() defer f.mux.Unlock() return f.details }
go
func (f *validationFailer) Details() []FailureDetail { f.mux.Lock() defer f.mux.Unlock() return f.details }
[ "func", "(", "f", "*", "validationFailer", ")", "Details", "(", ")", "[", "]", "FailureDetail", "{", "f", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mux", ".", "Unlock", "(", ")", "\n", "return", "f", ".", "details", "\n", "}" ]
// Details implements the Failures interface.
[ "Details", "implements", "the", "Failures", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L164-L168
150,236
tideland/golib
audit/failer.go
Errors
func (f *validationFailer) Errors() []error { f.mux.Lock() defer f.mux.Unlock() return f.errs }
go
func (f *validationFailer) Errors() []error { f.mux.Lock() defer f.mux.Unlock() return f.errs }
[ "func", "(", "f", "*", "validationFailer", ")", "Errors", "(", ")", "[", "]", "error", "{", "f", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mux", ".", "Unlock", "(", ")", "\n", "return", "f", ".", "errs", "\n", "}" ]
// Errors implements the Failures interface.
[ "Errors", "implements", "the", "Failures", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L171-L175
150,237
tideland/golib
audit/failer.go
Error
func (f *validationFailer) Error() error { f.mux.Lock() defer f.mux.Unlock() strs := []string{} for i, err := range f.errs { strs = append(strs, fmt.Sprintf("[%d] %v", i, err)) } return errors.New(strings.Join(strs, " / ")) }
go
func (f *validationFailer) Error() error { f.mux.Lock() defer f.mux.Unlock() strs := []string{} for i, err := range f.errs { strs = append(strs, fmt.Sprintf("[%d] %v", i, err)) } return errors.New(strings.Join(strs, " / ")) }
[ "func", "(", "f", "*", "validationFailer", ")", "Error", "(", ")", "error", "{", "f", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mux", ".", "Unlock", "(", ")", "\n", "strs", ":=", "[", "]", "string", "{", "}", "\n", "for", "...
// Error implements the Failures interface.
[ "Error", "implements", "the", "Failures", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L178-L186
150,238
tideland/golib
audit/failer.go
IncrCallstackOffset
func (f *validationFailer) IncrCallstackOffset() func() { f.mux.Lock() defer f.mux.Unlock() offset := f.offset f.offset++ return func() { f.mux.Lock() defer f.mux.Unlock() f.offset = offset } }
go
func (f *validationFailer) IncrCallstackOffset() func() { f.mux.Lock() defer f.mux.Unlock() offset := f.offset f.offset++ return func() { f.mux.Lock() defer f.mux.Unlock() f.offset = offset } }
[ "func", "(", "f", "*", "validationFailer", ")", "IncrCallstackOffset", "(", ")", "func", "(", ")", "{", "f", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mux", ".", "Unlock", "(", ")", "\n", "offset", ":=", "f", ".", "offset", "\n...
// IncrCallstackOffset implements the Failer interface.
[ "IncrCallstackOffset", "implements", "the", "Failer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L189-L199
150,239
tideland/golib
audit/failer.go
NewValidationAssertion
func NewValidationAssertion() (Assertion, Failures) { vf := &validationFailer{ offset: 2, details: []FailureDetail{}, errs: []error{}, } return NewAssertion(vf), vf }
go
func NewValidationAssertion() (Assertion, Failures) { vf := &validationFailer{ offset: 2, details: []FailureDetail{}, errs: []error{}, } return NewAssertion(vf), vf }
[ "func", "NewValidationAssertion", "(", ")", "(", "Assertion", ",", "Failures", ")", "{", "vf", ":=", "&", "validationFailer", "{", "offset", ":", "2", ",", "details", ":", "[", "]", "FailureDetail", "{", "}", ",", "errs", ":", "[", "]", "error", "{", ...
// NewValidationAssertion creates a new Assertion instance which collections // validation failures. The returned Failures instance allows to test an access // them.
[ "NewValidationAssertion", "creates", "a", "new", "Assertion", "instance", "which", "collections", "validation", "failures", ".", "The", "returned", "Failures", "instance", "allows", "to", "test", "an", "access", "them", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L242-L249
150,240
tideland/golib
audit/failer.go
IncrCallstackOffset
func (f *testingFailer) IncrCallstackOffset() func() { f.mux.Lock() defer f.mux.Unlock() offset := f.offset f.offset++ return func() { f.mux.Lock() defer f.mux.Unlock() f.offset = offset } }
go
func (f *testingFailer) IncrCallstackOffset() func() { f.mux.Lock() defer f.mux.Unlock() offset := f.offset f.offset++ return func() { f.mux.Lock() defer f.mux.Unlock() f.offset = offset } }
[ "func", "(", "f", "*", "testingFailer", ")", "IncrCallstackOffset", "(", ")", "func", "(", ")", "{", "f", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mux", ".", "Unlock", "(", ")", "\n", "offset", ":=", "f", ".", "offset", "\n", ...
// IncrCallstackOffset implements the failer interface.
[ "IncrCallstackOffset", "implements", "the", "failer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L271-L281
150,241
tideland/golib
audit/failer.go
Logf
func (f *testingFailer) Logf(format string, args ...interface{}) { f.mux.Lock() defer f.mux.Unlock() pc, file, line, _ := runtime.Caller(f.offset) _, fileName := path.Split(file) funcNameParts := strings.Split(runtime.FuncForPC(pc).Name(), ".") funcNamePartsIdx := len(funcNameParts) - 1 funcName := funcNameParts...
go
func (f *testingFailer) Logf(format string, args ...interface{}) { f.mux.Lock() defer f.mux.Unlock() pc, file, line, _ := runtime.Caller(f.offset) _, fileName := path.Split(file) funcNameParts := strings.Split(runtime.FuncForPC(pc).Name(), ".") funcNamePartsIdx := len(funcNameParts) - 1 funcName := funcNameParts...
[ "func", "(", "f", "*", "testingFailer", ")", "Logf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "f", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mux", ".", "Unlock", "(", ")", "\n", "pc", ",",...
// Logf implements the Failer interface.
[ "Logf", "implements", "the", "Failer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/failer.go#L284-L294
150,242
tideland/golib
logger/logger.go
SetLevel
func SetLevel(level LogLevel) LogLevel { logMux.Lock() defer logMux.Unlock() current := logLevel switch { case level <= LevelDebug: logLevel = LevelDebug case level >= LevelFatal: logLevel = LevelFatal default: logLevel = level } return current }
go
func SetLevel(level LogLevel) LogLevel { logMux.Lock() defer logMux.Unlock() current := logLevel switch { case level <= LevelDebug: logLevel = LevelDebug case level >= LevelFatal: logLevel = LevelFatal default: logLevel = level } return current }
[ "func", "SetLevel", "(", "level", "LogLevel", ")", "LogLevel", "{", "logMux", ".", "Lock", "(", ")", "\n", "defer", "logMux", ".", "Unlock", "(", ")", "\n", "current", ":=", "logLevel", "\n", "switch", "{", "case", "level", "<=", "LevelDebug", ":", "lo...
// SetLevel switches to a new log level and returns // the current one.
[ "SetLevel", "switches", "to", "a", "new", "log", "level", "and", "returns", "the", "current", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L86-L99
150,243
tideland/golib
logger/logger.go
SetLevelString
func SetLevelString(levelstr string) LogLevel { logMux.Lock() defer logMux.Unlock() current := logLevel switch strings.ToLower(levelstr) { case "debug": logLevel = LevelDebug case "info": logLevel = LevelInfo case "warning": logLevel = LevelWarning case "error": logLevel = LevelError case "critical": ...
go
func SetLevelString(levelstr string) LogLevel { logMux.Lock() defer logMux.Unlock() current := logLevel switch strings.ToLower(levelstr) { case "debug": logLevel = LevelDebug case "info": logLevel = LevelInfo case "warning": logLevel = LevelWarning case "error": logLevel = LevelError case "critical": ...
[ "func", "SetLevelString", "(", "levelstr", "string", ")", "LogLevel", "{", "logMux", ".", "Lock", "(", ")", "\n", "defer", "logMux", ".", "Unlock", "(", ")", "\n", "current", ":=", "logLevel", "\n", "switch", "strings", ".", "ToLower", "(", "levelstr", "...
// SetLevelString switches to a new log level passed as // string. Accepted are the values "debug", "info", "warning" // "error", "critical", and "fatal". The passed string will // be set to lower-case. The function is intended to be used // when then log level is read out of a configuration.
[ "SetLevelString", "switches", "to", "a", "new", "log", "level", "passed", "as", "string", ".", "Accepted", "are", "the", "values", "debug", "info", "warning", "error", "critical", "and", "fatal", ".", "The", "passed", "string", "will", "be", "set", "to", "...
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L106-L125
150,244
tideland/golib
logger/logger.go
SetLogger
func SetLogger(l Logger) Logger { logMux.Lock() defer logMux.Unlock() old := logBackend logBackend = l return old }
go
func SetLogger(l Logger) Logger { logMux.Lock() defer logMux.Unlock() old := logBackend logBackend = l return old }
[ "func", "SetLogger", "(", "l", "Logger", ")", "Logger", "{", "logMux", ".", "Lock", "(", ")", "\n", "defer", "logMux", ".", "Unlock", "(", ")", "\n", "old", ":=", "logBackend", "\n", "logBackend", "=", "l", "\n", "return", "old", "\n", "}" ]
// SetLogger sets a new logger.
[ "SetLogger", "sets", "a", "new", "logger", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L128-L134
150,245
tideland/golib
logger/logger.go
SetFatalExiter
func SetFatalExiter(fef FatalExiterFunc) FatalExiterFunc { logMux.Lock() defer logMux.Unlock() current := logFatalExiter logFatalExiter = fef return current }
go
func SetFatalExiter(fef FatalExiterFunc) FatalExiterFunc { logMux.Lock() defer logMux.Unlock() current := logFatalExiter logFatalExiter = fef return current }
[ "func", "SetFatalExiter", "(", "fef", "FatalExiterFunc", ")", "FatalExiterFunc", "{", "logMux", ".", "Lock", "(", ")", "\n", "defer", "logMux", ".", "Unlock", "(", ")", "\n", "current", ":=", "logFatalExiter", "\n", "logFatalExiter", "=", "fef", "\n", "retur...
// SetFatalExiter sets the fatal exiter function and // returns the current one.
[ "SetFatalExiter", "sets", "the", "fatal", "exiter", "function", "and", "returns", "the", "current", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L138-L144
150,246
tideland/golib
logger/logger.go
SetFilter
func SetFilter(ff FilterFunc) FilterFunc { logMux.Lock() defer logMux.Unlock() current := logFilter logFilter = ff return current }
go
func SetFilter(ff FilterFunc) FilterFunc { logMux.Lock() defer logMux.Unlock() current := logFilter logFilter = ff return current }
[ "func", "SetFilter", "(", "ff", "FilterFunc", ")", "FilterFunc", "{", "logMux", ".", "Lock", "(", ")", "\n", "defer", "logMux", ".", "Unlock", "(", ")", "\n", "current", ":=", "logFilter", "\n", "logFilter", "=", "ff", "\n", "return", "current", "\n", ...
// SetFilter sets the global output filter and returns // the current one.
[ "SetFilter", "sets", "the", "global", "output", "filter", "and", "returns", "the", "current", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L148-L154
150,247
tideland/golib
logger/logger.go
UnsetFilter
func UnsetFilter() FilterFunc { logMux.Lock() defer logMux.Unlock() current := logFilter logFilter = nil return current }
go
func UnsetFilter() FilterFunc { logMux.Lock() defer logMux.Unlock() current := logFilter logFilter = nil return current }
[ "func", "UnsetFilter", "(", ")", "FilterFunc", "{", "logMux", ".", "Lock", "(", ")", "\n", "defer", "logMux", ".", "Unlock", "(", ")", "\n", "current", ":=", "logFilter", "\n", "logFilter", "=", "nil", "\n", "return", "current", "\n", "}" ]
// UnsetFilter removes the global output folter and // returns the current one.
[ "UnsetFilter", "removes", "the", "global", "output", "folter", "and", "returns", "the", "current", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L158-L164
150,248
tideland/golib
logger/logger.go
Infof
func Infof(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() if logLevel <= LevelInfo { info := retrieveCallInfo().shortFormat() msg := fmt.Sprintf(format, args...) if shallLog(LevelInfo, info, msg) { logBackend.Info(info, msg) } } }
go
func Infof(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() if logLevel <= LevelInfo { info := retrieveCallInfo().shortFormat() msg := fmt.Sprintf(format, args...) if shallLog(LevelInfo, info, msg) { logBackend.Info(info, msg) } } }
[ "func", "Infof", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "logMux", ".", "RLock", "(", ")", "\n", "defer", "logMux", ".", "RUnlock", "(", ")", "\n", "if", "logLevel", "<=", "LevelInfo", "{", "info", ":=", "retriev...
// Infof logs a message at info level.
[ "Infof", "logs", "a", "message", "at", "info", "level", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L185-L196
150,249
tideland/golib
logger/logger.go
Warningf
func Warningf(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() if logLevel <= LevelWarning { info := retrieveCallInfo().shortFormat() msg := fmt.Sprintf(format, args...) if shallLog(LevelWarning, info, msg) { logBackend.Warning(info, msg) } } }
go
func Warningf(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() if logLevel <= LevelWarning { info := retrieveCallInfo().shortFormat() msg := fmt.Sprintf(format, args...) if shallLog(LevelWarning, info, msg) { logBackend.Warning(info, msg) } } }
[ "func", "Warningf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "logMux", ".", "RLock", "(", ")", "\n", "defer", "logMux", ".", "RUnlock", "(", ")", "\n", "if", "logLevel", "<=", "LevelWarning", "{", "info", ":=", "r...
// Warningf logs a message at warning level.
[ "Warningf", "logs", "a", "message", "at", "warning", "level", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L199-L210
150,250
tideland/golib
logger/logger.go
Errorf
func Errorf(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() if logLevel <= LevelError { info := retrieveCallInfo().shortFormat() msg := fmt.Sprintf(format, args...) if shallLog(LevelError, info, msg) { logBackend.Error(info, msg) } } }
go
func Errorf(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() if logLevel <= LevelError { info := retrieveCallInfo().shortFormat() msg := fmt.Sprintf(format, args...) if shallLog(LevelError, info, msg) { logBackend.Error(info, msg) } } }
[ "func", "Errorf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "logMux", ".", "RLock", "(", ")", "\n", "defer", "logMux", ".", "RUnlock", "(", ")", "\n", "if", "logLevel", "<=", "LevelError", "{", "info", ":=", "retri...
// Errorf logs a message at error level.
[ "Errorf", "logs", "a", "message", "at", "error", "level", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L213-L224
150,251
tideland/golib
logger/logger.go
Criticalf
func Criticalf(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() if logLevel <= LevelCritical { info := retrieveCallInfo().verboseFormat() msg := fmt.Sprintf(format, args...) if shallLog(LevelCritical, info, msg) { logBackend.Critical(info, msg) } } }
go
func Criticalf(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() if logLevel <= LevelCritical { info := retrieveCallInfo().verboseFormat() msg := fmt.Sprintf(format, args...) if shallLog(LevelCritical, info, msg) { logBackend.Critical(info, msg) } } }
[ "func", "Criticalf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "logMux", ".", "RLock", "(", ")", "\n", "defer", "logMux", ".", "RUnlock", "(", ")", "\n", "if", "logLevel", "<=", "LevelCritical", "{", "info", ":=", ...
// Criticalf logs a message at critical level.
[ "Criticalf", "logs", "a", "message", "at", "critical", "level", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L227-L238
150,252
tideland/golib
logger/logger.go
Fatalf
func Fatalf(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() info := retrieveCallInfo().verboseFormat() msg := fmt.Sprintf(format, args...) logBackend.Fatal(info, msg) logFatalExiter() }
go
func Fatalf(format string, args ...interface{}) { logMux.RLock() defer logMux.RUnlock() info := retrieveCallInfo().verboseFormat() msg := fmt.Sprintf(format, args...) logBackend.Fatal(info, msg) logFatalExiter() }
[ "func", "Fatalf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "logMux", ".", "RLock", "(", ")", "\n", "defer", "logMux", ".", "RUnlock", "(", ")", "\n", "info", ":=", "retrieveCallInfo", "(", ")", ".", "verboseFormat",...
// Fatalf logs a message independent of any level. After // logging the message the functions calls the fatal exiter // function, which by default means exiting the application // with error code -1.
[ "Fatalf", "logs", "a", "message", "independent", "of", "any", "level", ".", "After", "logging", "the", "message", "the", "functions", "calls", "the", "fatal", "exiter", "function", "which", "by", "default", "means", "exiting", "the", "application", "with", "er...
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L244-L252
150,253
tideland/golib
logger/logger.go
NewTimeformatLogger
func NewTimeformatLogger(out io.Writer, timeFormat string) Logger { return &standardLogger{ out: out, timeFormat: timeFormat, } }
go
func NewTimeformatLogger(out io.Writer, timeFormat string) Logger { return &standardLogger{ out: out, timeFormat: timeFormat, } }
[ "func", "NewTimeformatLogger", "(", "out", "io", ".", "Writer", ",", "timeFormat", "string", ")", "Logger", "{", "return", "&", "standardLogger", "{", "out", ":", "out", ",", "timeFormat", ":", "timeFormat", ",", "}", "\n", "}" ]
// NewTimeformatLogger creates a logger writing to the passed // output and with the time formatted with the passed time format.
[ "NewTimeformatLogger", "creates", "a", "logger", "writing", "to", "the", "passed", "output", "and", "with", "the", "time", "formatted", "with", "the", "passed", "time", "format", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L297-L302
150,254
tideland/golib
logger/logger.go
Info
func (sl *standardLogger) Info(info, msg string) { sl.writeLog("INFO", info, msg) }
go
func (sl *standardLogger) Info(info, msg string) { sl.writeLog("INFO", info, msg) }
[ "func", "(", "sl", "*", "standardLogger", ")", "Info", "(", "info", ",", "msg", "string", ")", "{", "sl", ".", "writeLog", "(", "\"", "\"", ",", "info", ",", "msg", ")", "\n", "}" ]
// Info implements Logger.
[ "Info", "implements", "Logger", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L316-L318
150,255
tideland/golib
logger/logger.go
Warning
func (sl *standardLogger) Warning(info, msg string) { sl.writeLog("WARNING", info, msg) }
go
func (sl *standardLogger) Warning(info, msg string) { sl.writeLog("WARNING", info, msg) }
[ "func", "(", "sl", "*", "standardLogger", ")", "Warning", "(", "info", ",", "msg", "string", ")", "{", "sl", ".", "writeLog", "(", "\"", "\"", ",", "info", ",", "msg", ")", "\n", "}" ]
// Warning implements Logger.
[ "Warning", "implements", "Logger", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L321-L323
150,256
tideland/golib
logger/logger.go
Critical
func (sl *standardLogger) Critical(info, msg string) { sl.writeLog("CRITICAL", info, msg) }
go
func (sl *standardLogger) Critical(info, msg string) { sl.writeLog("CRITICAL", info, msg) }
[ "func", "(", "sl", "*", "standardLogger", ")", "Critical", "(", "info", ",", "msg", "string", ")", "{", "sl", ".", "writeLog", "(", "\"", "\"", ",", "info", ",", "msg", ")", "\n", "}" ]
// Critical implements Logger.
[ "Critical", "implements", "Logger", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L331-L333
150,257
tideland/golib
logger/logger.go
Fatal
func (sl *standardLogger) Fatal(info, msg string) { sl.writeLog("FATAL", info, msg) }
go
func (sl *standardLogger) Fatal(info, msg string) { sl.writeLog("FATAL", info, msg) }
[ "func", "(", "sl", "*", "standardLogger", ")", "Fatal", "(", "info", ",", "msg", "string", ")", "{", "sl", ".", "writeLog", "(", "\"", "\"", ",", "info", ",", "msg", ")", "\n", "}" ]
// Fatal implements Logger.
[ "Fatal", "implements", "Logger", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L336-L338
150,258
tideland/golib
logger/logger.go
writeLog
func (sl *standardLogger) writeLog(level, info, msg string) { sl.mutex.Lock() defer sl.mutex.Unlock() io.WriteString(sl.out, time.Now().Format(sl.timeFormat)) io.WriteString(sl.out, " [") io.WriteString(sl.out, level) io.WriteString(sl.out, "] ") io.WriteString(sl.out, info) io.WriteString(sl.out, " ") io.Wri...
go
func (sl *standardLogger) writeLog(level, info, msg string) { sl.mutex.Lock() defer sl.mutex.Unlock() io.WriteString(sl.out, time.Now().Format(sl.timeFormat)) io.WriteString(sl.out, " [") io.WriteString(sl.out, level) io.WriteString(sl.out, "] ") io.WriteString(sl.out, info) io.WriteString(sl.out, " ") io.Wri...
[ "func", "(", "sl", "*", "standardLogger", ")", "writeLog", "(", "level", ",", "info", ",", "msg", "string", ")", "{", "sl", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "sl", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "io", ".", "Write...
// writeLog writes the log output.
[ "writeLog", "writes", "the", "log", "output", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L341-L353
150,259
tideland/golib
logger/logger.go
Len
func (tl *testLogger) Len() int { tl.mux.Lock() defer tl.mux.Unlock() return len(tl.entries) }
go
func (tl *testLogger) Len() int { tl.mux.Lock() defer tl.mux.Unlock() return len(tl.entries) }
[ "func", "(", "tl", "*", "testLogger", ")", "Len", "(", ")", "int", "{", "tl", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "tl", ".", "mux", ".", "Unlock", "(", ")", "\n", "return", "len", "(", "tl", ".", "entries", ")", "\n", "}" ]
// Len implements TestLogger.
[ "Len", "implements", "TestLogger", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L469-L473
150,260
tideland/golib
logger/logger.go
Entries
func (tl *testLogger) Entries() []string { tl.mux.Lock() defer tl.mux.Unlock() entries := make([]string, len(tl.entries)) copy(entries, tl.entries) return entries }
go
func (tl *testLogger) Entries() []string { tl.mux.Lock() defer tl.mux.Unlock() entries := make([]string, len(tl.entries)) copy(entries, tl.entries) return entries }
[ "func", "(", "tl", "*", "testLogger", ")", "Entries", "(", ")", "[", "]", "string", "{", "tl", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "tl", ".", "mux", ".", "Unlock", "(", ")", "\n", "entries", ":=", "make", "(", "[", "]", "string", ...
// Entries implements TestLogger.
[ "Entries", "implements", "TestLogger", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L476-L482
150,261
tideland/golib
logger/logger.go
Reset
func (tl *testLogger) Reset() { tl.mux.Lock() defer tl.mux.Unlock() tl.entries = nil }
go
func (tl *testLogger) Reset() { tl.mux.Lock() defer tl.mux.Unlock() tl.entries = nil }
[ "func", "(", "tl", "*", "testLogger", ")", "Reset", "(", ")", "{", "tl", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "tl", ".", "mux", ".", "Unlock", "(", ")", "\n", "tl", ".", "entries", "=", "nil", "\n", "}" ]
// Reset implements TestLogger.
[ "Reset", "implements", "TestLogger", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L485-L489
150,262
tideland/golib
logger/logger.go
verboseFormat
func (ci *callInfo) verboseFormat() string { return fmt.Sprintf("[%s] (%s:%s:%d)", ci.packageName, ci.fileName, ci.funcName, ci.line) }
go
func (ci *callInfo) verboseFormat() string { return fmt.Sprintf("[%s] (%s:%s:%d)", ci.packageName, ci.fileName, ci.funcName, ci.line) }
[ "func", "(", "ci", "*", "callInfo", ")", "verboseFormat", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ci", ".", "packageName", ",", "ci", ".", "fileName", ",", "ci", ".", "funcName", ",", "ci", ".", "line", ")",...
// verboseFormat returns a string representation in a more verbose variant.
[ "verboseFormat", "returns", "a", "string", "representation", "in", "a", "more", "verbose", "variant", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L510-L512
150,263
tideland/golib
logger/logger.go
shallLog
func shallLog(level LogLevel, info, msg string) bool { logMux.RLock() defer logMux.RUnlock() if logFilter == nil { return true } return !logFilter(level, info, msg) }
go
func shallLog(level LogLevel, info, msg string) bool { logMux.RLock() defer logMux.RUnlock() if logFilter == nil { return true } return !logFilter(level, info, msg) }
[ "func", "shallLog", "(", "level", "LogLevel", ",", "info", ",", "msg", "string", ")", "bool", "{", "logMux", ".", "RLock", "(", ")", "\n", "defer", "logMux", ".", "RUnlock", "(", ")", "\n", "if", "logFilter", "==", "nil", "{", "return", "true", "\n",...
// shallLog is used inside the logging functions to check if // logging is wanted.
[ "shallLog", "is", "used", "inside", "the", "logging", "functions", "to", "check", "if", "logging", "is", "wanted", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/logger.go#L541-L548
150,264
tideland/golib
feed/atom/atom.go
Validate
func (f *Feed) Validate() error { if f.XMLNS != XMLNS { return errors.New(ErrValidation, errorMessages, "invalid namespace %q: has to be %q", f.XMLNS, XMLNS) } if _, err := url.Parse(f.Id); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "feed id") } if err := validateText("feed title", f.T...
go
func (f *Feed) Validate() error { if f.XMLNS != XMLNS { return errors.New(ErrValidation, errorMessages, "invalid namespace %q: has to be %q", f.XMLNS, XMLNS) } if _, err := url.Parse(f.Id); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "feed id") } if err := validateText("feed title", f.T...
[ "func", "(", "f", "*", "Feed", ")", "Validate", "(", ")", "error", "{", "if", "f", ".", "XMLNS", "!=", "XMLNS", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ",", "f", ".", "XMLNS", ",", "XMLNS", ...
// Validate checks if the feed is valid.
[ "Validate", "checks", "if", "the", "feed", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L72-L127
150,265
tideland/golib
feed/atom/atom.go
PlainText
func (t Text) PlainText() (string, error) { // Retrieve the raw text. var raw string if t.Src != "" { resp, err := http.Get(t.Src) if err != nil { return "", errors.Annotate(err, ErrNoPlainText, errorMessages, t) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { retur...
go
func (t Text) PlainText() (string, error) { // Retrieve the raw text. var raw string if t.Src != "" { resp, err := http.Get(t.Src) if err != nil { return "", errors.Annotate(err, ErrNoPlainText, errorMessages, t) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { retur...
[ "func", "(", "t", "Text", ")", "PlainText", "(", ")", "(", "string", ",", "error", ")", "{", "// Retrieve the raw text.", "var", "raw", "string", "\n", "if", "t", ".", "Src", "!=", "\"", "\"", "{", "resp", ",", "err", ":=", "http", ".", "Get", "(",...
// PlainText returns the text as string without any markup. Content from // external sources will be retrieved.
[ "PlainText", "returns", "the", "text", "as", "string", "without", "any", "markup", ".", "Content", "from", "external", "sources", "will", "be", "retrieved", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L139-L170
150,266
tideland/golib
feed/atom/atom.go
validateText
func validateText(description string, t *Text, mandatory bool) error { if (t == nil || t.Text == "") && mandatory { return errors.New(ErrValidation, errorMessages, "%s must not be missing or empty", description) } if t != nil { if t.Src != "" { if _, err := url.Parse(t.Src); err != nil { what := fmt.Sprin...
go
func validateText(description string, t *Text, mandatory bool) error { if (t == nil || t.Text == "") && mandatory { return errors.New(ErrValidation, errorMessages, "%s must not be missing or empty", description) } if t != nil { if t.Src != "" { if _, err := url.Parse(t.Src); err != nil { what := fmt.Sprin...
[ "func", "validateText", "(", "description", "string", ",", "t", "*", "Text", ",", "mandatory", "bool", ")", "error", "{", "if", "(", "t", "==", "nil", "||", "t", ".", "Text", "==", "\"", "\"", ")", "&&", "mandatory", "{", "return", "errors", ".", "...
// validateText ensures that a text is set if it's mandatory and that // the type is correct.
[ "validateText", "ensures", "that", "a", "text", "is", "set", "if", "it", "s", "mandatory", "and", "that", "the", "type", "is", "correct", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L174-L193
150,267
tideland/golib
feed/atom/atom.go
Validate
func (a *Author) Validate() error { if a.Name == "" { return errors.New(ErrValidation, errorMessages, "feed author name must not be empty") } if a.URI != "" { if _, err := url.Parse(a.URI); err != nil { return errors.Annotate(err, ErrValidation, errorMessages, "feed author uri is not parsable") } } return...
go
func (a *Author) Validate() error { if a.Name == "" { return errors.New(ErrValidation, errorMessages, "feed author name must not be empty") } if a.URI != "" { if _, err := url.Parse(a.URI); err != nil { return errors.Annotate(err, ErrValidation, errorMessages, "feed author uri is not parsable") } } return...
[ "func", "(", "a", "*", "Author", ")", "Validate", "(", ")", "error", "{", "if", "a", ".", "Name", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "a",...
// Validate checks if a feed author is valid.
[ "Validate", "checks", "if", "a", "feed", "author", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L203-L213
150,268
tideland/golib
feed/atom/atom.go
Validate
func (l *Link) Validate() error { if _, err := url.Parse(l.HRef); err != nil { return errors.Annotate(err, ErrValidation, errorMessages, "feed link href is not parsable") } switch l.Rel { case "", AlternateRel, EnclosureRel, RelatedRel, SelfRel, ViaRel: // OK. default: if _, err := url.Parse(l.Rel); err != n...
go
func (l *Link) Validate() error { if _, err := url.Parse(l.HRef); err != nil { return errors.Annotate(err, ErrValidation, errorMessages, "feed link href is not parsable") } switch l.Rel { case "", AlternateRel, EnclosureRel, RelatedRel, SelfRel, ViaRel: // OK. default: if _, err := url.Parse(l.Rel); err != n...
[ "func", "(", "l", "*", "Link", ")", "Validate", "(", ")", "error", "{", "if", "_", ",", "err", ":=", "url", ".", "Parse", "(", "l", ".", "HRef", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "ErrValida...
// Validate checks if the feed link is valid.
[ "Validate", "checks", "if", "the", "feed", "link", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L226-L239
150,269
tideland/golib
feed/atom/atom.go
Validate
func (c *Category) Validate() error { if c.Term == "" { return errors.New(ErrValidation, errorMessages, "feed category term must not be empty") } if c.Scheme != "" { if _, err := url.Parse(c.Scheme); err != nil { return errors.Annotate(err, ErrValidation, errorMessages, "feed category scheme is not parsable")...
go
func (c *Category) Validate() error { if c.Term == "" { return errors.New(ErrValidation, errorMessages, "feed category term must not be empty") } if c.Scheme != "" { if _, err := url.Parse(c.Scheme); err != nil { return errors.Annotate(err, ErrValidation, errorMessages, "feed category scheme is not parsable")...
[ "func", "(", "c", "*", "Category", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "Term", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "c...
// Validate checks if a feed category is valid.
[ "Validate", "checks", "if", "a", "feed", "category", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L249-L259
150,270
tideland/golib
feed/atom/atom.go
Validate
func (c *Contributor) Validate() error { if c.Name == "" { return errors.New(ErrValidation, errorMessages, "feed contributor name must not be empty") } return nil }
go
func (c *Contributor) Validate() error { if c.Name == "" { return errors.New(ErrValidation, errorMessages, "feed contributor name must not be empty") } return nil }
[ "func", "(", "c", "*", "Contributor", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "Name", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "return...
// Validate checks if a feed contributor is valid.
[ "Validate", "checks", "if", "a", "feed", "contributor", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L267-L272
150,271
tideland/golib
feed/atom/atom.go
Validate
func (g *Generator) Validate() error { if g.Generator == "" { return errors.New(ErrValidation, errorMessages, "feed generator must not be empty") } if g.URI != "" { if _, err := url.Parse(g.URI); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "feed generator URI") } } return nil }
go
func (g *Generator) Validate() error { if g.Generator == "" { return errors.New(ErrValidation, errorMessages, "feed generator must not be empty") } if g.URI != "" { if _, err := url.Parse(g.URI); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "feed generator URI") } } return nil }
[ "func", "(", "g", "*", "Generator", ")", "Validate", "(", ")", "error", "{", "if", "g", ".", "Generator", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "ErrValidation", ",", "errorMessages", ",", "\"", "\"", ")", "\n", "}", "\n", "if"...
// Validate checks if a feed generator is valid.
[ "Validate", "checks", "if", "a", "feed", "generator", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L283-L293
150,272
tideland/golib
feed/atom/atom.go
Validate
func (e *Entry) Validate() error { if _, err := url.Parse(e.Id); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "feed entry id") } if err := validateText("feed entry title", e.Title, true); err != nil { return err } if _, err := ParseTime(e.Updated); err != nil { return errors.Annotate(e...
go
func (e *Entry) Validate() error { if _, err := url.Parse(e.Id); err != nil { return errors.Annotate(err, ErrParsing, errorMessages, "feed entry id") } if err := validateText("feed entry title", e.Title, true); err != nil { return err } if _, err := ParseTime(e.Updated); err != nil { return errors.Annotate(e...
[ "func", "(", "e", "*", "Entry", ")", "Validate", "(", ")", "error", "{", "if", "_", ",", "err", ":=", "url", ".", "Parse", "(", "e", ".", "Id", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "ErrParsing...
// Validate checks if the feed entry is valid.
[ "Validate", "checks", "if", "the", "feed", "entry", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L312-L360
150,273
tideland/golib
feed/atom/atom.go
Validate
func (s *Source) Validate() error { for _, author := range s.Authors { if err := author.Validate(); err != nil { return err } } for _, category := range s.Categories { if err := category.Validate(); err != nil { return err } } for _, contributor := range s.Contributors { if err := contributor.Valid...
go
func (s *Source) Validate() error { for _, author := range s.Authors { if err := author.Validate(); err != nil { return err } } for _, category := range s.Categories { if err := category.Validate(); err != nil { return err } } for _, contributor := range s.Contributors { if err := contributor.Valid...
[ "func", "(", "s", "*", "Source", ")", "Validate", "(", ")", "error", "{", "for", "_", ",", "author", ":=", "range", "s", ".", "Authors", "{", "if", "err", ":=", "author", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", ...
// Validate checks if a feed entry source is valid.
[ "Validate", "checks", "if", "a", "feed", "entry", "source", "is", "valid", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L380-L422
150,274
tideland/golib
feed/atom/atom.go
Encode
func Encode(w io.Writer, feed *Feed) error { enc := xml.NewEncoder(w) if _, err := w.Write([]byte(xml.Header)); err != nil { return err } return enc.Encode(feed) }
go
func Encode(w io.Writer, feed *Feed) error { enc := xml.NewEncoder(w) if _, err := w.Write([]byte(xml.Header)); err != nil { return err } return enc.Encode(feed) }
[ "func", "Encode", "(", "w", "io", ".", "Writer", ",", "feed", "*", "Feed", ")", "error", "{", "enc", ":=", "xml", ".", "NewEncoder", "(", "w", ")", "\n", "if", "_", ",", "err", ":=", "w", ".", "Write", "(", "[", "]", "byte", "(", "xml", ".", ...
// Encode writes the feed to the writer.
[ "Encode", "writes", "the", "feed", "to", "the", "writer", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L446-L452
150,275
tideland/golib
feed/atom/atom.go
Decode
func Decode(r io.Reader) (*Feed, error) { dec := xml.NewDecoder(r) dec.CharsetReader = utils.CharsetReader feed := &Feed{} if err := dec.Decode(feed); err != nil { return nil, err } return feed, nil }
go
func Decode(r io.Reader) (*Feed, error) { dec := xml.NewDecoder(r) dec.CharsetReader = utils.CharsetReader feed := &Feed{} if err := dec.Decode(feed); err != nil { return nil, err } return feed, nil }
[ "func", "Decode", "(", "r", "io", ".", "Reader", ")", "(", "*", "Feed", ",", "error", ")", "{", "dec", ":=", "xml", ".", "NewDecoder", "(", "r", ")", "\n", "dec", ".", "CharsetReader", "=", "utils", ".", "CharsetReader", "\n", "feed", ":=", "&", ...
// Decode reads the feed from the reader.
[ "Decode", "reads", "the", "feed", "from", "the", "reader", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/feed/atom/atom.go#L455-L463
150,276
tideland/golib
cache/cache.go
ID
func ID(id string) Option { return func(c Cache) error { switch oc := c.(type) { case *cache: oc.id = id return nil default: return errors.New(ErrIllegalCache, errorMessages) } } }
go
func ID(id string) Option { return func(c Cache) error { switch oc := c.(type) { case *cache: oc.id = id return nil default: return errors.New(ErrIllegalCache, errorMessages) } } }
[ "func", "ID", "(", "id", "string", ")", "Option", "{", "return", "func", "(", "c", "Cache", ")", "error", "{", "switch", "oc", ":=", "c", ".", "(", "type", ")", "{", "case", "*", "cache", ":", "oc", ".", "id", "=", "id", "\n", "return", "nil", ...
// ID returns the option to set the cache ID.
[ "ID", "returns", "the", "option", "to", "set", "the", "cache", "ID", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L66-L76
150,277
tideland/golib
cache/cache.go
Loader
func Loader(l CacheableLoader) Option { return func(c Cache) error { switch oc := c.(type) { case *cache: oc.load = l return nil default: return errors.New(ErrIllegalCache, errorMessages) } } }
go
func Loader(l CacheableLoader) Option { return func(c Cache) error { switch oc := c.(type) { case *cache: oc.load = l return nil default: return errors.New(ErrIllegalCache, errorMessages) } } }
[ "func", "Loader", "(", "l", "CacheableLoader", ")", "Option", "{", "return", "func", "(", "c", "Cache", ")", "error", "{", "switch", "oc", ":=", "c", ".", "(", "type", ")", "{", "case", "*", "cache", ":", "oc", ".", "load", "=", "l", "\n", "retur...
// Loader returns the option to set the loader function.
[ "Loader", "returns", "the", "option", "to", "set", "the", "loader", "function", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L79-L89
150,278
tideland/golib
cache/cache.go
Interval
func Interval(d time.Duration) Option { return func(c Cache) error { switch oc := c.(type) { case *cache: oc.interval = d return nil default: return errors.New(ErrIllegalCache, errorMessages) } } }
go
func Interval(d time.Duration) Option { return func(c Cache) error { switch oc := c.(type) { case *cache: oc.interval = d return nil default: return errors.New(ErrIllegalCache, errorMessages) } } }
[ "func", "Interval", "(", "d", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "Cache", ")", "error", "{", "switch", "oc", ":=", "c", ".", "(", "type", ")", "{", "case", "*", "cache", ":", "oc", ".", "interval", "=", "d", ...
// Interval returns the option to set the cleanup check interval.
[ "Interval", "returns", "the", "option", "to", "set", "the", "cleanup", "check", "interval", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L92-L102
150,279
tideland/golib
cache/cache.go
TTL
func TTL(d time.Duration) Option { return func(c Cache) error { switch oc := c.(type) { case *cache: oc.ttl = d return nil default: return errors.New(ErrIllegalCache, errorMessages) } } }
go
func TTL(d time.Duration) Option { return func(c Cache) error { switch oc := c.(type) { case *cache: oc.ttl = d return nil default: return errors.New(ErrIllegalCache, errorMessages) } } }
[ "func", "TTL", "(", "d", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "c", "Cache", ")", "error", "{", "switch", "oc", ":=", "c", ".", "(", "type", ")", "{", "case", "*", "cache", ":", "oc", ".", "ttl", "=", "d", "\n", ...
// TTL returns the option to set the time to live for Cacheables.
[ "TTL", "returns", "the", "option", "to", "set", "the", "time", "to", "live", "for", "Cacheables", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L105-L115
150,280
tideland/golib
cache/cache.go
Load
func (c *cache) Load(id string, timeout time.Duration) (Cacheable, error) { // Send lookup task. responsec := make(responder, 1) c.taskc <- lookupTask(id, responsec) // Receive response. select { case response := <-responsec: cacheable, err := response() return cacheable, err case <-time.After(timeout): re...
go
func (c *cache) Load(id string, timeout time.Duration) (Cacheable, error) { // Send lookup task. responsec := make(responder, 1) c.taskc <- lookupTask(id, responsec) // Receive response. select { case response := <-responsec: cacheable, err := response() return cacheable, err case <-time.After(timeout): re...
[ "func", "(", "c", "*", "cache", ")", "Load", "(", "id", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "Cacheable", ",", "error", ")", "{", "// Send lookup task.", "responsec", ":=", "make", "(", "responder", ",", "1", ")", "\n", "c", "...
// Load implements the Cache interface.
[ "Load", "implements", "the", "Cache", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L200-L212
150,281
tideland/golib
cache/cache.go
Discard
func (c *cache) Discard(id string) error { // Send discard task. responsec := make(responder, 1) c.taskc <- discardTask(id, responsec) // Receive response. select { case response := <-responsec: _, err := response() return err case <-time.After(5 * time.Second): return errors.New(ErrTimeout, errorMessages,...
go
func (c *cache) Discard(id string) error { // Send discard task. responsec := make(responder, 1) c.taskc <- discardTask(id, responsec) // Receive response. select { case response := <-responsec: _, err := response() return err case <-time.After(5 * time.Second): return errors.New(ErrTimeout, errorMessages,...
[ "func", "(", "c", "*", "cache", ")", "Discard", "(", "id", "string", ")", "error", "{", "// Send discard task.", "responsec", ":=", "make", "(", "responder", ",", "1", ")", "\n", "c", ".", "taskc", "<-", "discardTask", "(", "id", ",", "responsec", ")",...
// Discard implements the Cache interface.
[ "Discard", "implements", "the", "Cache", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L215-L227
150,282
tideland/golib
cache/cache.go
Clear
func (c *cache) Clear() error { // Send clear task. responsec := make(responder, 1) c.taskc <- clearTask(responsec) // Receive response. select { case response := <-responsec: _, err := response() return err case <-time.After(5 * time.Second): return errors.New(ErrTimeout, errorMessages, "discarding") } }
go
func (c *cache) Clear() error { // Send clear task. responsec := make(responder, 1) c.taskc <- clearTask(responsec) // Receive response. select { case response := <-responsec: _, err := response() return err case <-time.After(5 * time.Second): return errors.New(ErrTimeout, errorMessages, "discarding") } }
[ "func", "(", "c", "*", "cache", ")", "Clear", "(", ")", "error", "{", "// Send clear task.", "responsec", ":=", "make", "(", "responder", ",", "1", ")", "\n", "c", ".", "taskc", "<-", "clearTask", "(", "responsec", ")", "\n", "// Receive response.", "sel...
// Clear implements the Cache interface.
[ "Clear", "implements", "the", "Cache", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L230-L242
150,283
tideland/golib
cache/cache.go
Len
func (c *cache) Len() int { // Send info task. lenc := make(chan int, 1) c.lenc <- lenc // Receive response. l := <-lenc return l }
go
func (c *cache) Len() int { // Send info task. lenc := make(chan int, 1) c.lenc <- lenc // Receive response. l := <-lenc return l }
[ "func", "(", "c", "*", "cache", ")", "Len", "(", ")", "int", "{", "// Send info task.", "lenc", ":=", "make", "(", "chan", "int", ",", "1", ")", "\n", "c", ".", "lenc", "<-", "lenc", "\n", "// Receive response.", "l", ":=", "<-", "lenc", "\n", "ret...
// Len implements the Cache interface.
[ "Len", "implements", "the", "Cache", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L245-L252
150,284
tideland/golib
cache/cache.go
backendLoop
func (c *cache) backendLoop(l loop.Loop) error { // Prepare ticker for lifetime check. checker := time.NewTicker(c.interval) defer checker.Stop() // Run loop. for { select { case <-l.ShallStop(): return nil case do := <-c.taskc: if err := do(c); err != nil { return err } case lenc := <-c.lenc:...
go
func (c *cache) backendLoop(l loop.Loop) error { // Prepare ticker for lifetime check. checker := time.NewTicker(c.interval) defer checker.Stop() // Run loop. for { select { case <-l.ShallStop(): return nil case do := <-c.taskc: if err := do(c); err != nil { return err } case lenc := <-c.lenc:...
[ "func", "(", "c", "*", "cache", ")", "backendLoop", "(", "l", "loop", ".", "Loop", ")", "error", "{", "// Prepare ticker for lifetime check.", "checker", ":=", "time", ".", "NewTicker", "(", "c", ".", "interval", ")", "\n", "defer", "checker", ".", "Stop",...
// backendLoop runs the cache.
[ "backendLoop", "runs", "the", "cache", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L260-L281
150,285
tideland/golib
cache/cache.go
cleanup
func (c *cache) cleanup() error { unused := []string{} now := time.Now() // First find old ones. for id, bucket := range c.buckets { if bucket.status == statusLoading { continue } if bucket.lastUsed.Add(c.ttl).Before(now) { unused = append(unused, id) } } // Now delete found ones. var errs []error ...
go
func (c *cache) cleanup() error { unused := []string{} now := time.Now() // First find old ones. for id, bucket := range c.buckets { if bucket.status == statusLoading { continue } if bucket.lastUsed.Add(c.ttl).Before(now) { unused = append(unused, id) } } // Now delete found ones. var errs []error ...
[ "func", "(", "c", "*", "cache", ")", "cleanup", "(", ")", "error", "{", "unused", ":=", "[", "]", "string", "{", "}", "\n", "now", ":=", "time", ".", "Now", "(", ")", "\n", "// First find old ones.", "for", "id", ",", "bucket", ":=", "range", "c", ...
// cleanup looks for too long unused Cacheables // and removes them.
[ "cleanup", "looks", "for", "too", "long", "unused", "Cacheables", "and", "removes", "them", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/cache/cache.go#L285-L310
150,286
tideland/golib
loop/sentinel.go
goSentinel
func goSentinel(nhf NotificationHandlerFunc, ps *sentinel, d string) *sentinel { s := &sentinel{ descr: d, handlerF: nhf, observables: make(map[Observable]struct{}), addC: make(chan *observableChange), removeC: make(chan *observableChange), notifyC: make(chan Observable), } s.loop...
go
func goSentinel(nhf NotificationHandlerFunc, ps *sentinel, d string) *sentinel { s := &sentinel{ descr: d, handlerF: nhf, observables: make(map[Observable]struct{}), addC: make(chan *observableChange), removeC: make(chan *observableChange), notifyC: make(chan Observable), } s.loop...
[ "func", "goSentinel", "(", "nhf", "NotificationHandlerFunc", ",", "ps", "*", "sentinel", ",", "d", "string", ")", "*", "sentinel", "{", "s", ":=", "&", "sentinel", "{", "descr", ":", "d", ",", "handlerF", ":", "nhf", ",", "observables", ":", "make", "(...
// goSentinel starts a new sentinel.
[ "goSentinel", "starts", "a", "new", "sentinel", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/sentinel.go#L63-L74
150,287
tideland/golib
loop/sentinel.go
Observe
func (s *sentinel) Observe(os ...Observable) { change := &observableChange{ observables: os, doneC: make(chan struct{}), } s.addC <- change <-change.doneC }
go
func (s *sentinel) Observe(os ...Observable) { change := &observableChange{ observables: os, doneC: make(chan struct{}), } s.addC <- change <-change.doneC }
[ "func", "(", "s", "*", "sentinel", ")", "Observe", "(", "os", "...", "Observable", ")", "{", "change", ":=", "&", "observableChange", "{", "observables", ":", "os", ",", "doneC", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "s...
// Observe implements the Sentinel interface.
[ "Observe", "implements", "the", "Sentinel", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/sentinel.go#L119-L126
150,288
tideland/golib
loop/sentinel.go
Forget
func (s *sentinel) Forget(os ...Observable) { change := &observableChange{ observables: os, doneC: make(chan struct{}), } s.removeC <- change <-change.doneC }
go
func (s *sentinel) Forget(os ...Observable) { change := &observableChange{ observables: os, doneC: make(chan struct{}), } s.removeC <- change <-change.doneC }
[ "func", "(", "s", "*", "sentinel", ")", "Forget", "(", "os", "...", "Observable", ")", "{", "change", ":=", "&", "observableChange", "{", "observables", ":", "os", ",", "doneC", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "s"...
// Forget implements the Sentinel interface.
[ "Forget", "implements", "the", "Sentinel", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/sentinel.go#L129-L136
150,289
tideland/golib
loop/sentinel.go
ObservablesDo
func (s *sentinel) ObservablesDo(f func(o Observable) error) error { s.mux.Lock() defer s.mux.Unlock() var errs []error for observable := range s.observables { if err := f(observable); err != nil { errs = append(errs, err) } } if len(errs) > 0 { return errors.Collect(errs...) } return nil }
go
func (s *sentinel) ObservablesDo(f func(o Observable) error) error { s.mux.Lock() defer s.mux.Unlock() var errs []error for observable := range s.observables { if err := f(observable); err != nil { errs = append(errs, err) } } if len(errs) > 0 { return errors.Collect(errs...) } return nil }
[ "func", "(", "s", "*", "sentinel", ")", "ObservablesDo", "(", "f", "func", "(", "o", "Observable", ")", "error", ")", "error", "{", "s", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mux", ".", "Unlock", "(", ")", "\n", "var", "e...
// ObservablesDo implements the Sentinel interface.
[ "ObservablesDo", "implements", "the", "Sentinel", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/sentinel.go#L139-L152
150,290
tideland/golib
loop/sentinel.go
backendLoop
func (s *sentinel) backendLoop(l Loop) error { var recoverings Recoverings for { select { case <-l.ShallStop(): // We're done. return s.ObservablesDo(func(o Observable) error { logger.Infof("sentinel %q stops observable %q", s, o) o.Stop() return nil }) case change := <-s.addC: // Add ne...
go
func (s *sentinel) backendLoop(l Loop) error { var recoverings Recoverings for { select { case <-l.ShallStop(): // We're done. return s.ObservablesDo(func(o Observable) error { logger.Infof("sentinel %q stops observable %q", s, o) o.Stop() return nil }) case change := <-s.addC: // Add ne...
[ "func", "(", "s", "*", "sentinel", ")", "backendLoop", "(", "l", "Loop", ")", "error", "{", "var", "recoverings", "Recoverings", "\n", "for", "{", "select", "{", "case", "<-", "l", ".", "ShallStop", "(", ")", ":", "// We're done.", "return", "s", ".", ...
// backendLoop listens to ending managed loops.
[ "backendLoop", "listens", "to", "ending", "managed", "loops", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/sentinel.go#L155-L206
150,291
tideland/golib
sml/reader.go
ReadSML
func ReadSML(reader io.Reader, builder Builder) error { s := &mlReader{ reader: bufio.NewReader(reader), builder: builder, index: -1, } if err := s.readPreliminary(); err != nil { return err } return s.readTagNode() }
go
func ReadSML(reader io.Reader, builder Builder) error { s := &mlReader{ reader: bufio.NewReader(reader), builder: builder, index: -1, } if err := s.readPreliminary(); err != nil { return err } return s.readTagNode() }
[ "func", "ReadSML", "(", "reader", "io", ".", "Reader", ",", "builder", "Builder", ")", "error", "{", "s", ":=", "&", "mlReader", "{", "reader", ":", "bufio", ".", "NewReader", "(", "reader", ")", ",", "builder", ":", "builder", ",", "index", ":", "-"...
// ReadSML parses a SML document and uses the passed builder // for the callbacks.
[ "ReadSML", "parses", "a", "SML", "document", "and", "uses", "the", "passed", "builder", "for", "the", "callbacks", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L52-L62
150,292
tideland/golib
sml/reader.go
readPreliminary
func (mr *mlReader) readPreliminary() error { for { _, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading preliminary") case rc == rcOpen: return nil } } }
go
func (mr *mlReader) readPreliminary() error { for { _, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading preliminary") case rc == rcOpen: return nil } } }
[ "func", "(", "mr", "*", "mlReader", ")", "readPreliminary", "(", ")", "error", "{", "for", "{", "_", ",", "rc", ",", "err", ":=", "mr", ".", "readRune", "(", ")", "\n", "switch", "{", "case", "err", "!=", "nil", ":", "return", "err", "\n", "case"...
// readPreliminary reads the content before the first node.
[ "readPreliminary", "reads", "the", "content", "before", "the", "first", "node", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L73-L85
150,293
tideland/golib
sml/reader.go
readTagNode
func (mr *mlReader) readTagNode() error { tag, rc, err := mr.readTag() if err != nil { return err } if err = mr.builder.BeginTagNode(tag); err != nil { return err } // Read children. if rc != rcClose { if err = mr.readTagChildren(); err != nil { return err } } return mr.builder.EndTagNode() }
go
func (mr *mlReader) readTagNode() error { tag, rc, err := mr.readTag() if err != nil { return err } if err = mr.builder.BeginTagNode(tag); err != nil { return err } // Read children. if rc != rcClose { if err = mr.readTagChildren(); err != nil { return err } } return mr.builder.EndTagNode() }
[ "func", "(", "mr", "*", "mlReader", ")", "readTagNode", "(", ")", "error", "{", "tag", ",", "rc", ",", "err", ":=", "mr", ".", "readTag", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", "=", "mr", ...
// readNode reads the next tag node.
[ "readNode", "reads", "the", "next", "tag", "node", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L88-L103
150,294
tideland/golib
sml/reader.go
readTag
func (mr *mlReader) readTag() (string, int, error) { var buf bytes.Buffer for { r, rc, err := mr.readRune() switch { case err != nil: return "", 0, err case rc == rcEOF: return "", 0, errors.New(ErrReader, errorMessages, "unexpected end of file while reading a tag") case rc == rcTag: buf.WriteRune(...
go
func (mr *mlReader) readTag() (string, int, error) { var buf bytes.Buffer for { r, rc, err := mr.readRune() switch { case err != nil: return "", 0, err case rc == rcEOF: return "", 0, errors.New(ErrReader, errorMessages, "unexpected end of file while reading a tag") case rc == rcTag: buf.WriteRune(...
[ "func", "(", "mr", "*", "mlReader", ")", "readTag", "(", ")", "(", "string", ",", "int", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "{", "r", ",", "rc", ",", "err", ":=", "mr", ".", "readRune", "(", ")", "\n", ...
// readTag reads the tag of a node. It als returns the class of the next rune.
[ "readTag", "reads", "the", "tag", "of", "a", "node", ".", "It", "als", "returns", "the", "class", "of", "the", "next", "rune", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L106-L124
150,295
tideland/golib
sml/reader.go
readTagChildren
func (mr *mlReader) readTagChildren() error { for { _, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading children") case rc == rcClose: return nil case rc == rcOpen: if err = mr.readB...
go
func (mr *mlReader) readTagChildren() error { for { _, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading children") case rc == rcClose: return nil case rc == rcOpen: if err = mr.readB...
[ "func", "(", "mr", "*", "mlReader", ")", "readTagChildren", "(", ")", "error", "{", "for", "{", "_", ",", "rc", ",", "err", ":=", "mr", ".", "readRune", "(", ")", "\n", "switch", "{", "case", "err", "!=", "nil", ":", "return", "err", "\n", "case"...
// readTagChildren reads the children of parent tag node.
[ "readTagChildren", "reads", "the", "children", "of", "parent", "tag", "node", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L127-L149
150,296
tideland/golib
sml/reader.go
readBracedContent
func (mr *mlReader) readBracedContent() error { _, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading a tag or raw node") case rc == rcTag: mr.index-- mr.reader.UnreadRune() return mr.readTagNod...
go
func (mr *mlReader) readBracedContent() error { _, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading a tag or raw node") case rc == rcTag: mr.index-- mr.reader.UnreadRune() return mr.readTagNod...
[ "func", "(", "mr", "*", "mlReader", ")", "readBracedContent", "(", ")", "error", "{", "_", ",", "rc", ",", "err", ":=", "mr", ".", "readRune", "(", ")", "\n", "switch", "{", "case", "err", "!=", "nil", ":", "return", "err", "\n", "case", "rc", "=...
// readBracedContent checks if the opening is for a tag node, raw node, // or comment and starts the reading of it.
[ "readBracedContent", "checks", "if", "the", "opening", "is", "for", "a", "tag", "node", "raw", "node", "or", "comment", "and", "starts", "the", "reading", "of", "it", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L153-L171
150,297
tideland/golib
sml/reader.go
readRawNode
func (mr *mlReader) readRawNode() error { var buf bytes.Buffer for { r, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading a raw node") case rc == rcExclamation: r, rc, err = mr.readRune()...
go
func (mr *mlReader) readRawNode() error { var buf bytes.Buffer for { r, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading a raw node") case rc == rcExclamation: r, rc, err = mr.readRune()...
[ "func", "(", "mr", "*", "mlReader", ")", "readRawNode", "(", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "{", "r", ",", "rc", ",", "err", ":=", "mr", ".", "readRune", "(", ")", "\n", "switch", "{", "case", "err", "!=", ...
// readRawNode reads a raw node.
[ "readRawNode", "reads", "a", "raw", "node", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L174-L199
150,298
tideland/golib
sml/reader.go
readCommentNode
func (mr *mlReader) readCommentNode() error { var buf bytes.Buffer for { r, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading a comment node") case rc == rcHash: r, rc, err = mr.readRune(...
go
func (mr *mlReader) readCommentNode() error { var buf bytes.Buffer for { r, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading a comment node") case rc == rcHash: r, rc, err = mr.readRune(...
[ "func", "(", "mr", "*", "mlReader", ")", "readCommentNode", "(", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "{", "r", ",", "rc", ",", "err", ":=", "mr", ".", "readRune", "(", ")", "\n", "switch", "{", "case", "err", "!=...
// readCommentNode reads a raw node.
[ "readCommentNode", "reads", "a", "raw", "node", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L202-L227
150,299
tideland/golib
sml/reader.go
readTextNode
func (mr *mlReader) readTextNode() error { var buf bytes.Buffer for { r, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading a text node") case rc == rcOpen || rc == rcClose: mr.index-- ...
go
func (mr *mlReader) readTextNode() error { var buf bytes.Buffer for { r, rc, err := mr.readRune() switch { case err != nil: return err case rc == rcEOF: return errors.New(ErrReader, errorMessages, "unexpected end of file while reading a text node") case rc == rcOpen || rc == rcClose: mr.index-- ...
[ "func", "(", "mr", "*", "mlReader", ")", "readTextNode", "(", ")", "error", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "{", "r", ",", "rc", ",", "err", ":=", "mr", ".", "readRune", "(", ")", "\n", "switch", "{", "case", "err", "!=", ...
// readTextNode reads a text node.
[ "readTextNode", "reads", "a", "text", "node", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/reader.go#L230-L260