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,100
tideland/golib
audit/generators.go
Paragraph
func (g *Generator) Paragraph() string { count := g.Int(2, 10) sentences := make([]string, count) for i := 0; i < count; i++ { sentences[i] = g.Sentence() } return strings.Join(sentences, " ") }
go
func (g *Generator) Paragraph() string { count := g.Int(2, 10) sentences := make([]string, count) for i := 0; i < count; i++ { sentences[i] = g.Sentence() } return strings.Join(sentences, " ") }
[ "func", "(", "g", "*", "Generator", ")", "Paragraph", "(", ")", "string", "{", "count", ":=", "g", ".", "Int", "(", "2", ",", "10", ")", "\n", "sentences", ":=", "make", "(", "[", "]", "string", ",", "count", ")", "\n", "for", "i", ":=", "0", ...
// Paragraph generates a paragraph between 2 and 10 sentences.
[ "Paragraph", "generates", "a", "paragraph", "between", "2", "and", "10", "sentences", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L287-L294
150,101
tideland/golib
audit/generators.go
Name
func (g *Generator) Name() (first, middle, last string) { if g.FlipCoin(50) { return g.FemaleName() } return g.MaleName() }
go
func (g *Generator) Name() (first, middle, last string) { if g.FlipCoin(50) { return g.FemaleName() } return g.MaleName() }
[ "func", "(", "g", "*", "Generator", ")", "Name", "(", ")", "(", "first", ",", "middle", ",", "last", "string", ")", "{", "if", "g", ".", "FlipCoin", "(", "50", ")", "{", "return", "g", ".", "FemaleName", "(", ")", "\n", "}", "\n", "return", "g"...
// Name generates a male or female name consisting out of first, // middle and last name.
[ "Name", "generates", "a", "male", "or", "female", "name", "consisting", "out", "of", "first", "middle", "and", "last", "name", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L298-L303
150,102
tideland/golib
audit/generators.go
MaleName
func (g *Generator) MaleName() (first, middle, last string) { first = g.OneStringOf(maleFirstNames...) middle = g.OneStringOf(maleFirstNames...) if g.FlipCoin(80) { first += "-" + g.OneStringOf(maleFirstNames...) } else if g.FlipCoin(80) { middle += "-" + g.OneStringOf(maleFirstNames...) } last = g.OneStringO...
go
func (g *Generator) MaleName() (first, middle, last string) { first = g.OneStringOf(maleFirstNames...) middle = g.OneStringOf(maleFirstNames...) if g.FlipCoin(80) { first += "-" + g.OneStringOf(maleFirstNames...) } else if g.FlipCoin(80) { middle += "-" + g.OneStringOf(maleFirstNames...) } last = g.OneStringO...
[ "func", "(", "g", "*", "Generator", ")", "MaleName", "(", ")", "(", "first", ",", "middle", ",", "last", "string", ")", "{", "first", "=", "g", ".", "OneStringOf", "(", "maleFirstNames", "...", ")", "\n", "middle", "=", "g", ".", "OneStringOf", "(", ...
// MaleName generates a male name consisting out of first, middle // and last name.
[ "MaleName", "generates", "a", "male", "name", "consisting", "out", "of", "first", "middle", "and", "last", "name", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L307-L317
150,103
tideland/golib
audit/generators.go
FemaleName
func (g *Generator) FemaleName() (first, middle, last string) { first = g.OneStringOf(femaleFirstNames...) middle = g.OneStringOf(femaleFirstNames...) if g.FlipCoin(80) { first += "-" + g.OneStringOf(femaleFirstNames...) } else if g.FlipCoin(80) { middle += "-" + g.OneStringOf(femaleFirstNames...) } last = g....
go
func (g *Generator) FemaleName() (first, middle, last string) { first = g.OneStringOf(femaleFirstNames...) middle = g.OneStringOf(femaleFirstNames...) if g.FlipCoin(80) { first += "-" + g.OneStringOf(femaleFirstNames...) } else if g.FlipCoin(80) { middle += "-" + g.OneStringOf(femaleFirstNames...) } last = g....
[ "func", "(", "g", "*", "Generator", ")", "FemaleName", "(", ")", "(", "first", ",", "middle", ",", "last", "string", ")", "{", "first", "=", "g", ".", "OneStringOf", "(", "femaleFirstNames", "...", ")", "\n", "middle", "=", "g", ".", "OneStringOf", "...
// FemaleName generates a female name consisting out of first, middle // and last name.
[ "FemaleName", "generates", "a", "female", "name", "consisting", "out", "of", "first", "middle", "and", "last", "name", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L321-L331
150,104
tideland/golib
audit/generators.go
Domain
func (g *Generator) Domain() string { tld := g.OneStringOf(topLevelDomains...) if g.FlipCoin(80) { return g.LimitedWord(3, 5) + "-" + g.LimitedWord(3, 5) + "." + tld } return g.LimitedWord(3, 10) + "." + tld }
go
func (g *Generator) Domain() string { tld := g.OneStringOf(topLevelDomains...) if g.FlipCoin(80) { return g.LimitedWord(3, 5) + "-" + g.LimitedWord(3, 5) + "." + tld } return g.LimitedWord(3, 10) + "." + tld }
[ "func", "(", "g", "*", "Generator", ")", "Domain", "(", ")", "string", "{", "tld", ":=", "g", ".", "OneStringOf", "(", "topLevelDomains", "...", ")", "\n", "if", "g", ".", "FlipCoin", "(", "80", ")", "{", "return", "g", ".", "LimitedWord", "(", "3"...
// Domain generates domain out of name and top level domain.
[ "Domain", "generates", "domain", "out", "of", "name", "and", "top", "level", "domain", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L334-L340
150,105
tideland/golib
audit/generators.go
URL
func (g *Generator) URL() string { part := func() string { return g.LimitedWord(2, 8) } start := g.OneStringOf("http://www.", "http://blog.", "https://www.", "ftp://") ext := g.OneStringOf("html", "php", "jpg", "mp3", "txt") variant := g.Percent() switch { case variant < 20: return start + part() + "." + g.D...
go
func (g *Generator) URL() string { part := func() string { return g.LimitedWord(2, 8) } start := g.OneStringOf("http://www.", "http://blog.", "https://www.", "ftp://") ext := g.OneStringOf("html", "php", "jpg", "mp3", "txt") variant := g.Percent() switch { case variant < 20: return start + part() + "." + g.D...
[ "func", "(", "g", "*", "Generator", ")", "URL", "(", ")", "string", "{", "part", ":=", "func", "(", ")", "string", "{", "return", "g", ".", "LimitedWord", "(", "2", ",", "8", ")", "\n", "}", "\n", "start", ":=", "g", ".", "OneStringOf", "(", "\...
// URL generates a http, https or ftp URL, some of the leading // to a file.
[ "URL", "generates", "a", "http", "https", "or", "ftp", "URL", "some", "of", "the", "leading", "to", "a", "file", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L344-L359
150,106
tideland/golib
audit/generators.go
EMail
func (g *Generator) EMail() string { if g.FlipCoin(50) { first, _, last := g.MaleName() return BuildEMail(first, last, g.Domain()) } first, _, last := g.FemaleName() return BuildEMail(first, last, g.Domain()) }
go
func (g *Generator) EMail() string { if g.FlipCoin(50) { first, _, last := g.MaleName() return BuildEMail(first, last, g.Domain()) } first, _, last := g.FemaleName() return BuildEMail(first, last, g.Domain()) }
[ "func", "(", "g", "*", "Generator", ")", "EMail", "(", ")", "string", "{", "if", "g", ".", "FlipCoin", "(", "50", ")", "{", "first", ",", "_", ",", "last", ":=", "g", ".", "MaleName", "(", ")", "\n", "return", "BuildEMail", "(", "first", ",", "...
// EMail returns a random e-mail address.
[ "EMail", "returns", "a", "random", "e", "-", "mail", "address", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L362-L369
150,107
tideland/golib
audit/generators.go
Duration
func (g *Generator) Duration(lo, hi time.Duration) time.Duration { if lo == hi { return lo } if lo > hi { lo, hi = hi, lo } n := g.rand.Int63n(int64(hi) - int64(lo) + 1) return lo + time.Duration(n) }
go
func (g *Generator) Duration(lo, hi time.Duration) time.Duration { if lo == hi { return lo } if lo > hi { lo, hi = hi, lo } n := g.rand.Int63n(int64(hi) - int64(lo) + 1) return lo + time.Duration(n) }
[ "func", "(", "g", "*", "Generator", ")", "Duration", "(", "lo", ",", "hi", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "if", "lo", "==", "hi", "{", "return", "lo", "\n", "}", "\n", "if", "lo", ">", "hi", "{", "lo", ",", "hi", ...
// Duration generates a duration between lo and hi including // those values.
[ "Duration", "generates", "a", "duration", "between", "lo", "and", "hi", "including", "those", "values", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L373-L382
150,108
tideland/golib
audit/generators.go
SleepOneOf
func (g *Generator) SleepOneOf(sleeps ...time.Duration) time.Duration { sleep := g.OneDurationOf(sleeps...) time.Sleep(sleep) return sleep }
go
func (g *Generator) SleepOneOf(sleeps ...time.Duration) time.Duration { sleep := g.OneDurationOf(sleeps...) time.Sleep(sleep) return sleep }
[ "func", "(", "g", "*", "Generator", ")", "SleepOneOf", "(", "sleeps", "...", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "sleep", ":=", "g", ".", "OneDurationOf", "(", "sleeps", "...", ")", "\n", "time", ".", "Sleep", "(", "sleep", ")...
// SleepOneOf chooses randomely one of the passed durations // and lets the goroutine sleep for this time.
[ "SleepOneOf", "chooses", "randomely", "one", "of", "the", "passed", "durations", "and", "lets", "the", "goroutine", "sleep", "for", "this", "time", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L386-L390
150,109
tideland/golib
audit/generators.go
Time
func (g *Generator) Time(loc *time.Location, base time.Time, dur time.Duration) time.Time { base = base.UTC() return base.Add(g.Duration(0, dur)).In(loc) }
go
func (g *Generator) Time(loc *time.Location, base time.Time, dur time.Duration) time.Time { base = base.UTC() return base.Add(g.Duration(0, dur)).In(loc) }
[ "func", "(", "g", "*", "Generator", ")", "Time", "(", "loc", "*", "time", ".", "Location", ",", "base", "time", ".", "Time", ",", "dur", "time", ".", "Duration", ")", "time", ".", "Time", "{", "base", "=", "base", ".", "UTC", "(", ")", "\n", "r...
// Time generates a time between the given one and that time // plus the given duration. The result will have the passed // location.
[ "Time", "generates", "a", "time", "between", "the", "given", "one", "and", "that", "time", "plus", "the", "given", "duration", ".", "The", "result", "will", "have", "the", "passed", "location", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/generators.go#L395-L398
150,110
tideland/golib
gjp/value.go
AsString
func (v *value) AsString(dv string) string { if v.IsUndefined() { return dv } switch tv := v.raw.(type) { case string: return tv case int: return strconv.Itoa(tv) case float64: return strconv.FormatFloat(tv, 'f', -1, 64) case bool: return strconv.FormatBool(tv) } return dv }
go
func (v *value) AsString(dv string) string { if v.IsUndefined() { return dv } switch tv := v.raw.(type) { case string: return tv case int: return strconv.Itoa(tv) case float64: return strconv.FormatFloat(tv, 'f', -1, 64) case bool: return strconv.FormatBool(tv) } return dv }
[ "func", "(", "v", "*", "value", ")", "AsString", "(", "dv", "string", ")", "string", "{", "if", "v", ".", "IsUndefined", "(", ")", "{", "return", "dv", "\n", "}", "\n", "switch", "tv", ":=", "v", ".", "raw", ".", "(", "type", ")", "{", "case", ...
// AsString implements Value.
[ "AsString", "implements", "Value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/value.go#L59-L74
150,111
tideland/golib
gjp/value.go
AsInt
func (v *value) AsInt(dv int) int { if v.IsUndefined() { return dv } switch tv := v.raw.(type) { case string: i, err := strconv.Atoi(tv) if err != nil { return dv } return i case int: return tv case float64: return int(tv) case bool: if tv { return 1 } return 0 } return dv }
go
func (v *value) AsInt(dv int) int { if v.IsUndefined() { return dv } switch tv := v.raw.(type) { case string: i, err := strconv.Atoi(tv) if err != nil { return dv } return i case int: return tv case float64: return int(tv) case bool: if tv { return 1 } return 0 } return dv }
[ "func", "(", "v", "*", "value", ")", "AsInt", "(", "dv", "int", ")", "int", "{", "if", "v", ".", "IsUndefined", "(", ")", "{", "return", "dv", "\n", "}", "\n", "switch", "tv", ":=", "v", ".", "raw", ".", "(", "type", ")", "{", "case", "string...
// AsInt implements Value.
[ "AsInt", "implements", "Value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/value.go#L77-L99
150,112
tideland/golib
gjp/value.go
AsFloat64
func (v *value) AsFloat64(dv float64) float64 { if v.IsUndefined() { return dv } switch tv := v.raw.(type) { case string: f, err := strconv.ParseFloat(tv, 64) if err != nil { return dv } return f case int: return float64(tv) case float64: return tv case bool: if tv { return 1.0 } return...
go
func (v *value) AsFloat64(dv float64) float64 { if v.IsUndefined() { return dv } switch tv := v.raw.(type) { case string: f, err := strconv.ParseFloat(tv, 64) if err != nil { return dv } return f case int: return float64(tv) case float64: return tv case bool: if tv { return 1.0 } return...
[ "func", "(", "v", "*", "value", ")", "AsFloat64", "(", "dv", "float64", ")", "float64", "{", "if", "v", ".", "IsUndefined", "(", ")", "{", "return", "dv", "\n", "}", "\n", "switch", "tv", ":=", "v", ".", "raw", ".", "(", "type", ")", "{", "case...
// AsFloat64 implements Value.
[ "AsFloat64", "implements", "Value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/value.go#L102-L124
150,113
tideland/golib
gjp/value.go
AsBool
func (v *value) AsBool(dv bool) bool { if v.IsUndefined() { return dv } switch tv := v.raw.(type) { case string: b, err := strconv.ParseBool(tv) if err != nil { return dv } return b case int: return tv == 1 case float64: return tv == 1.0 case bool: return tv } return dv }
go
func (v *value) AsBool(dv bool) bool { if v.IsUndefined() { return dv } switch tv := v.raw.(type) { case string: b, err := strconv.ParseBool(tv) if err != nil { return dv } return b case int: return tv == 1 case float64: return tv == 1.0 case bool: return tv } return dv }
[ "func", "(", "v", "*", "value", ")", "AsBool", "(", "dv", "bool", ")", "bool", "{", "if", "v", ".", "IsUndefined", "(", ")", "{", "return", "dv", "\n", "}", "\n", "switch", "tv", ":=", "v", ".", "raw", ".", "(", "type", ")", "{", "case", "str...
// AsBool implements Value.
[ "AsBool", "implements", "Value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/value.go#L127-L146
150,114
tideland/golib
gjp/value.go
Equals
func (v *value) Equals(to Value) bool { vto, ok := to.(*value) if !ok { return false } if vv, ok := isValue(v.raw); ok { if vtov, ok := isValue(vto.raw); ok { return vv == vtov } } return reflect.DeepEqual(v.raw, vto.raw) }
go
func (v *value) Equals(to Value) bool { vto, ok := to.(*value) if !ok { return false } if vv, ok := isValue(v.raw); ok { if vtov, ok := isValue(vto.raw); ok { return vv == vtov } } return reflect.DeepEqual(v.raw, vto.raw) }
[ "func", "(", "v", "*", "value", ")", "Equals", "(", "to", "Value", ")", "bool", "{", "vto", ",", "ok", ":=", "to", ".", "(", "*", "value", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "if", "vv", ",", "ok", ":=", "is...
// Equals implements Value.
[ "Equals", "implements", "Value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/value.go#L149-L160
150,115
tideland/golib
redis/pool.go
newPool
func newPool(db *Database) *pool { p := &pool{ database: db, available: make(map[*resp]*resp), inUse: make(map[*resp]*resp), requestChan: make(chan *poolRequest), } p.backend = loop.Go(p.backendLoop, "redis", db.address, db.index) return p }
go
func newPool(db *Database) *pool { p := &pool{ database: db, available: make(map[*resp]*resp), inUse: make(map[*resp]*resp), requestChan: make(chan *poolRequest), } p.backend = loop.Go(p.backendLoop, "redis", db.address, db.index) return p }
[ "func", "newPool", "(", "db", "*", "Database", ")", "*", "pool", "{", "p", ":=", "&", "pool", "{", "database", ":", "db", ",", "available", ":", "make", "(", "map", "[", "*", "resp", "]", "*", "resp", ")", ",", "inUse", ":", "make", "(", "map",...
// newPool creates a connection pool with uninitialized // protocol instances.
[ "newPool", "creates", "a", "connection", "pool", "with", "uninitialized", "protocol", "instances", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pool.go#L59-L68
150,116
tideland/golib
redis/pool.go
pull
func (p *pool) pull(forced bool) (*resp, error) { if forced { return p.do(forcedPullRequest, nil) } wait := 5 * time.Millisecond for i := 0; i < 5; i++ { resp, err := p.do(unforcedPullRequest, nil) if err != nil { return nil, err } if resp != nil { return resp, nil } time.Sleep(wait) wait = wa...
go
func (p *pool) pull(forced bool) (*resp, error) { if forced { return p.do(forcedPullRequest, nil) } wait := 5 * time.Millisecond for i := 0; i < 5; i++ { resp, err := p.do(unforcedPullRequest, nil) if err != nil { return nil, err } if resp != nil { return resp, nil } time.Sleep(wait) wait = wa...
[ "func", "(", "p", "*", "pool", ")", "pull", "(", "forced", "bool", ")", "(", "*", "resp", ",", "error", ")", "{", "if", "forced", "{", "return", "p", ".", "do", "(", "forcedPullRequest", ",", "nil", ")", "\n", "}", "\n", "wait", ":=", "5", "*",...
// pull returns a protocol out of the pool. If none is available // but the configured pool sized isn't reached a new one will be // established.
[ "pull", "returns", "a", "protocol", "out", "of", "the", "pool", ".", "If", "none", "is", "available", "but", "the", "configured", "pool", "sized", "isn", "t", "reached", "a", "new", "one", "will", "be", "established", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pool.go#L73-L90
150,117
tideland/golib
redis/pool.go
push
func (p *pool) push(resp *resp) error { _, err := p.do(pushRequest, resp) return err }
go
func (p *pool) push(resp *resp) error { _, err := p.do(pushRequest, resp) return err }
[ "func", "(", "p", "*", "pool", ")", "push", "(", "resp", "*", "resp", ")", "error", "{", "_", ",", "err", ":=", "p", ".", "do", "(", "pushRequest", ",", "resp", ")", "\n", "return", "err", "\n", "}" ]
// push returns a protocol back into the pool.
[ "push", "returns", "a", "protocol", "back", "into", "the", "pool", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pool.go#L93-L96
150,118
tideland/golib
redis/pool.go
kill
func (p *pool) kill(resp *resp) error { _, err := p.do(killRequest, resp) return err }
go
func (p *pool) kill(resp *resp) error { _, err := p.do(killRequest, resp) return err }
[ "func", "(", "p", "*", "pool", ")", "kill", "(", "resp", "*", "resp", ")", "error", "{", "_", ",", "err", ":=", "p", ".", "do", "(", "killRequest", ",", "resp", ")", "\n", "return", "err", "\n", "}" ]
// kill closes the connection and removes it from the pool.
[ "kill", "closes", "the", "connection", "and", "removes", "it", "from", "the", "pool", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pool.go#L99-L102
150,119
tideland/golib
redis/pool.go
close
func (p *pool) close() error { _, err := p.do(closeRequest, nil) return err }
go
func (p *pool) close() error { _, err := p.do(closeRequest, nil) return err }
[ "func", "(", "p", "*", "pool", ")", "close", "(", ")", "error", "{", "_", ",", "err", ":=", "p", ".", "do", "(", "closeRequest", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
// close closes all pooled protocol instances, first the available ones, // then the ones in use.
[ "close", "closes", "all", "pooled", "protocol", "instances", "first", "the", "available", "ones", "then", "the", "ones", "in", "use", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pool.go#L106-L109
150,120
tideland/golib
redis/pool.go
do
func (p *pool) do(kind int, resp *resp) (*resp, error) { request := &poolRequest{ kind: kind, resp: resp, responseChan: make(chan *poolResponse, 1), } p.requestChan <- request response := <-request.responseChan return response.resp, response.err }
go
func (p *pool) do(kind int, resp *resp) (*resp, error) { request := &poolRequest{ kind: kind, resp: resp, responseChan: make(chan *poolResponse, 1), } p.requestChan <- request response := <-request.responseChan return response.resp, response.err }
[ "func", "(", "p", "*", "pool", ")", "do", "(", "kind", "int", ",", "resp", "*", "resp", ")", "(", "*", "resp", ",", "error", ")", "{", "request", ":=", "&", "poolRequest", "{", "kind", ":", "kind", ",", "resp", ":", "resp", ",", "responseChan", ...
// do executes one request.
[ "do", "executes", "one", "request", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pool.go#L112-L121
150,121
tideland/golib
redis/pool.go
respond
func (p *pool) respond(request *poolRequest, resp *resp, err error) { response := &poolResponse{ resp: resp, err: err, } request.responseChan <- response }
go
func (p *pool) respond(request *poolRequest, resp *resp, err error) { response := &poolResponse{ resp: resp, err: err, } request.responseChan <- response }
[ "func", "(", "p", "*", "pool", ")", "respond", "(", "request", "*", "poolRequest", ",", "resp", "*", "resp", ",", "err", "error", ")", "{", "response", ":=", "&", "poolResponse", "{", "resp", ":", "resp", ",", "err", ":", "err", ",", "}", "\n", "...
// respond answers to a request.
[ "respond", "answers", "to", "a", "request", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pool.go#L124-L130
150,122
tideland/golib
redis/pool.go
backendLoop
func (p *pool) backendLoop(l loop.Loop) error { for { select { case <-l.ShallStop(): return nil case request := <-p.requestChan: // Handle the request. switch request.kind { case forcedPullRequest: // Always return a new protocol. resp, err := newResp(p.database) if err != nil { p.re...
go
func (p *pool) backendLoop(l loop.Loop) error { for { select { case <-l.ShallStop(): return nil case request := <-p.requestChan: // Handle the request. switch request.kind { case forcedPullRequest: // Always return a new protocol. resp, err := newResp(p.database) if err != nil { p.re...
[ "func", "(", "p", "*", "pool", ")", "backendLoop", "(", "l", "loop", ".", "Loop", ")", "error", "{", "for", "{", "select", "{", "case", "<-", "l", ".", "ShallStop", "(", ")", ":", "return", "nil", "\n", "case", "request", ":=", "<-", "p", ".", ...
// backendLoop manages the pool in a serialized way.
[ "backendLoop", "manages", "the", "pool", "in", "a", "serialized", "way", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/redis/pool.go#L133-L195
150,123
tideland/golib
logger/syslogger.go
NewSysLogger
func NewSysLogger(tag string) (Logger, error) { writer, err := syslog.New(syslog.LOG_DEBUG|syslog.LOG_LOCAL0, tag) if err != nil { log.Fatalf("cannot init syslog: %v", err) return nil, err } return &SysLogger{writer}, nil }
go
func NewSysLogger(tag string) (Logger, error) { writer, err := syslog.New(syslog.LOG_DEBUG|syslog.LOG_LOCAL0, tag) if err != nil { log.Fatalf("cannot init syslog: %v", err) return nil, err } return &SysLogger{writer}, nil }
[ "func", "NewSysLogger", "(", "tag", "string", ")", "(", "Logger", ",", "error", ")", "{", "writer", ",", "err", ":=", "syslog", ".", "New", "(", "syslog", ".", "LOG_DEBUG", "|", "syslog", ".", "LOG_LOCAL0", ",", "tag", ")", "\n", "if", "err", "!=", ...
// NewSysLogger returns a logger implementation using the // Go syslog package.
[ "NewSysLogger", "returns", "a", "logger", "implementation", "using", "the", "Go", "syslog", "package", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/logger/syslogger.go#L33-L40
150,124
tideland/golib
numerics/numerics.go
IsInf
func (p Point) IsInf() bool { return math.IsInf(p.x, 0) || math.IsInf(p.y, 0) }
go
func (p Point) IsInf() bool { return math.IsInf(p.x, 0) || math.IsInf(p.y, 0) }
[ "func", "(", "p", "Point", ")", "IsInf", "(", ")", "bool", "{", "return", "math", ".", "IsInf", "(", "p", ".", "x", ",", "0", ")", "||", "math", ".", "IsInf", "(", "p", ".", "y", ",", "0", ")", "\n", "}" ]
// IsInf checks if x or y is infinite.
[ "IsInf", "checks", "if", "x", "or", "y", "is", "infinite", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L37-L39
150,125
tideland/golib
numerics/numerics.go
IsNaN
func (p Point) IsNaN() bool { return math.IsNaN(p.x) || math.IsNaN(p.y) }
go
func (p Point) IsNaN() bool { return math.IsNaN(p.x) || math.IsNaN(p.y) }
[ "func", "(", "p", "Point", ")", "IsNaN", "(", ")", "bool", "{", "return", "math", ".", "IsNaN", "(", "p", ".", "x", ")", "||", "math", ".", "IsNaN", "(", "p", ".", "y", ")", "\n", "}" ]
// IsNaN checks if x or y is not a number.
[ "IsNaN", "checks", "if", "x", "or", "y", "is", "not", "a", "number", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L42-L44
150,126
tideland/golib
numerics/numerics.go
DistanceTo
func (p Point) DistanceTo(op *Point) float64 { dx := p.x - op.x dy := p.y - op.y return math.Sqrt(dx*dx + dy*dy) }
go
func (p Point) DistanceTo(op *Point) float64 { dx := p.x - op.x dy := p.y - op.y return math.Sqrt(dx*dx + dy*dy) }
[ "func", "(", "p", "Point", ")", "DistanceTo", "(", "op", "*", "Point", ")", "float64", "{", "dx", ":=", "p", ".", "x", "-", "op", ".", "x", "\n", "dy", ":=", "p", ".", "y", "-", "op", ".", "y", "\n", "return", "math", ".", "Sqrt", "(", "dx"...
// DistanceTo takes another point and calculates the // geometric distance.
[ "DistanceTo", "takes", "another", "point", "and", "calculates", "the", "geometric", "distance", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L58-L62
150,127
tideland/golib
numerics/numerics.go
VectorTo
func (p Point) VectorTo(op *Point) *Vector { return NewVector(op.X()-p.x, op.Y()-p.y) }
go
func (p Point) VectorTo(op *Point) *Vector { return NewVector(op.X()-p.x, op.Y()-p.y) }
[ "func", "(", "p", "Point", ")", "VectorTo", "(", "op", "*", "Point", ")", "*", "Vector", "{", "return", "NewVector", "(", "op", ".", "X", "(", ")", "-", "p", ".", "x", ",", "op", ".", "Y", "(", ")", "-", "p", ".", "y", ")", "\n", "}" ]
// VectorTo returns the vector to another point.
[ "VectorTo", "returns", "the", "vector", "to", "another", "point", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L65-L67
150,128
tideland/golib
numerics/numerics.go
String
func (p Point) String() string { return fmt.Sprintf("(%f, %f)", p.x, p.y) }
go
func (p Point) String() string { return fmt.Sprintf("(%f, %f)", p.x, p.y) }
[ "func", "(", "p", "Point", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "x", ",", "p", ".", "y", ")", "\n", "}" ]
// String returns the string representation of the coordinates.
[ "String", "returns", "the", "string", "representation", "of", "the", "coordinates", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L70-L72
150,129
tideland/golib
numerics/numerics.go
MiddlePoint
func MiddlePoint(a, b *Point) *Point { return NewPoint((a.x+b.x)/2, (a.y+b.y)/2) }
go
func MiddlePoint(a, b *Point) *Point { return NewPoint((a.x+b.x)/2, (a.y+b.y)/2) }
[ "func", "MiddlePoint", "(", "a", ",", "b", "*", "Point", ")", "*", "Point", "{", "return", "NewPoint", "(", "(", "a", ".", "x", "+", "b", ".", "x", ")", "/", "2", ",", "(", "a", ".", "y", "+", "b", ".", "y", ")", "/", "2", ")", "\n", "}...
// MiddlePoint returns the middle point between two points.
[ "MiddlePoint", "returns", "the", "middle", "point", "between", "two", "points", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L75-L77
150,130
tideland/golib
numerics/numerics.go
XDifference
func (ps Points) XDifference(idxA, idxB int) float64 { return ps[idxA].X() - ps[idxB].X() }
go
func (ps Points) XDifference(idxA, idxB int) float64 { return ps[idxA].X() - ps[idxB].X() }
[ "func", "(", "ps", "Points", ")", "XDifference", "(", "idxA", ",", "idxB", "int", ")", "float64", "{", "return", "ps", "[", "idxA", "]", ".", "X", "(", ")", "-", "ps", "[", "idxB", "]", ".", "X", "(", ")", "\n", "}" ]
// XDifference returns the difference between two X // values of the set.
[ "XDifference", "returns", "the", "difference", "between", "two", "X", "values", "of", "the", "set", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L111-L113
150,131
tideland/golib
numerics/numerics.go
YDifference
func (ps Points) YDifference(idxA, idxB int) float64 { return ps[idxA].Y() - ps[idxB].Y() }
go
func (ps Points) YDifference(idxA, idxB int) float64 { return ps[idxA].Y() - ps[idxB].Y() }
[ "func", "(", "ps", "Points", ")", "YDifference", "(", "idxA", ",", "idxB", "int", ")", "float64", "{", "return", "ps", "[", "idxA", "]", ".", "Y", "(", ")", "-", "ps", "[", "idxB", "]", ".", "Y", "(", ")", "\n", "}" ]
// YDifference returns the difference between two Y // values of the set.
[ "YDifference", "returns", "the", "difference", "between", "two", "Y", "values", "of", "the", "set", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L117-L119
150,132
tideland/golib
numerics/numerics.go
XInRange
func (ps Points) XInRange(x float64) bool { minX := ps[0].X() maxX := ps[0].X() for _, p := range ps[1:] { if p.X() < minX { minX = p.X() } if p.X() > maxX { maxX = p.X() } } return minX <= x && x <= maxX }
go
func (ps Points) XInRange(x float64) bool { minX := ps[0].X() maxX := ps[0].X() for _, p := range ps[1:] { if p.X() < minX { minX = p.X() } if p.X() > maxX { maxX = p.X() } } return minX <= x && x <= maxX }
[ "func", "(", "ps", "Points", ")", "XInRange", "(", "x", "float64", ")", "bool", "{", "minX", ":=", "ps", "[", "0", "]", ".", "X", "(", ")", "\n", "maxX", ":=", "ps", "[", "0", "]", ".", "X", "(", ")", "\n", "for", "_", ",", "p", ":=", "ra...
// XInRange tests if an X value is in the range of X // values of the set.
[ "XInRange", "tests", "if", "an", "X", "value", "is", "in", "the", "range", "of", "X", "values", "of", "the", "set", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L123-L135
150,133
tideland/golib
numerics/numerics.go
SearchNextIndex
func (ps Points) SearchNextIndex(x float64) int { sf := func(i int) bool { return x < ps[i].X() } return sort.Search(len(ps), sf) }
go
func (ps Points) SearchNextIndex(x float64) int { sf := func(i int) bool { return x < ps[i].X() } return sort.Search(len(ps), sf) }
[ "func", "(", "ps", "Points", ")", "SearchNextIndex", "(", "x", "float64", ")", "int", "{", "sf", ":=", "func", "(", "i", "int", ")", "bool", "{", "return", "x", "<", "ps", "[", "i", "]", ".", "X", "(", ")", "\n", "}", "\n", "return", "sort", ...
// SearchNextIndex searches the next index fo a // given X value.
[ "SearchNextIndex", "searches", "the", "next", "index", "fo", "a", "given", "X", "value", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L139-L144
150,134
tideland/golib
numerics/numerics.go
Less
func (ps Points) Less(i, j int) bool { // Check X first. switch { case ps[i].x < ps[j].x: return true case ps[i].x > ps[j].x: return false } // Now check Y. switch { case ps[i].y < ps[j].y: return true case ps[i].y > ps[j].y: return false } return false }
go
func (ps Points) Less(i, j int) bool { // Check X first. switch { case ps[i].x < ps[j].x: return true case ps[i].x > ps[j].x: return false } // Now check Y. switch { case ps[i].y < ps[j].y: return true case ps[i].y > ps[j].y: return false } return false }
[ "func", "(", "ps", "Points", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "// Check X first.", "switch", "{", "case", "ps", "[", "i", "]", ".", "x", "<", "ps", "[", "j", "]", ".", "x", ":", "return", "true", "\n", "case", "ps", "...
// Less returns true if the point with index i is less then the // one with index j. It first looks for X, then for Y.
[ "Less", "returns", "true", "if", "the", "point", "with", "index", "i", "is", "less", "then", "the", "one", "with", "index", "j", ".", "It", "first", "looks", "for", "X", "then", "for", "Y", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L153-L169
150,135
tideland/golib
numerics/numerics.go
Swap
func (ps Points) Swap(i, j int) { ps[i], ps[j] = ps[j], ps[i] }
go
func (ps Points) Swap(i, j int) { ps[i], ps[j] = ps[j], ps[i] }
[ "func", "(", "ps", "Points", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "ps", "[", "i", "]", ",", "ps", "[", "j", "]", "=", "ps", "[", "j", "]", ",", "ps", "[", "i", "]", "\n", "}" ]
// Swap swaps two points of the set.
[ "Swap", "swaps", "two", "points", "of", "the", "set", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L172-L174
150,136
tideland/golib
numerics/numerics.go
String
func (ps Points) String() string { pss := "{" for _, p := range ps { pss += p.String() } pss += "}" return pss }
go
func (ps Points) String() string { pss := "{" for _, p := range ps { pss += p.String() } pss += "}" return pss }
[ "func", "(", "ps", "Points", ")", "String", "(", ")", "string", "{", "pss", ":=", "\"", "\"", "\n", "for", "_", ",", "p", ":=", "range", "ps", "{", "pss", "+=", "p", ".", "String", "(", ")", "\n", "}", "\n", "pss", "+=", "\"", "\"", "\n", "...
// String returns the string representation of the set.
[ "String", "returns", "the", "string", "representation", "of", "the", "set", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L187-L194
150,137
tideland/golib
numerics/numerics.go
Len
func (v Vector) Len() float64 { return math.Sqrt(v.x*v.x + v.y*v.y) }
go
func (v Vector) Len() float64 { return math.Sqrt(v.x*v.x + v.y*v.y) }
[ "func", "(", "v", "Vector", ")", "Len", "(", ")", "float64", "{", "return", "math", ".", "Sqrt", "(", "v", ".", "x", "*", "v", ".", "x", "+", "v", ".", "y", "*", "v", ".", "y", ")", "\n", "}" ]
// Len returns the length of the vector.
[ "Len", "returns", "the", "length", "of", "the", "vector", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L223-L225
150,138
tideland/golib
numerics/numerics.go
String
func (v Vector) String() string { return fmt.Sprintf("<%f, %f>", v.x, v.y) }
go
func (v Vector) String() string { return fmt.Sprintf("<%f, %f>", v.x, v.y) }
[ "func", "(", "v", "Vector", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ".", "x", ",", "v", ".", "y", ")", "\n", "}" ]
// String returns the string representation of the vector.
[ "String", "returns", "the", "string", "representation", "of", "the", "vector", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L228-L230
150,139
tideland/golib
numerics/numerics.go
AddVectors
func AddVectors(a, b *Vector) *Vector { return NewVector(a.x+b.x, a.y+b.y) }
go
func AddVectors(a, b *Vector) *Vector { return NewVector(a.x+b.x, a.y+b.y) }
[ "func", "AddVectors", "(", "a", ",", "b", "*", "Vector", ")", "*", "Vector", "{", "return", "NewVector", "(", "a", ".", "x", "+", "b", ".", "x", ",", "a", ".", "y", "+", "b", ".", "y", ")", "\n", "}" ]
// AddVectors returns a new vector as addition of two vectors.
[ "AddVectors", "returns", "a", "new", "vector", "as", "addition", "of", "two", "vectors", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L233-L235
150,140
tideland/golib
numerics/numerics.go
SubVectors
func SubVectors(a, b *Vector) *Vector { return NewVector(a.x-b.x, a.y-b.y) }
go
func SubVectors(a, b *Vector) *Vector { return NewVector(a.x-b.x, a.y-b.y) }
[ "func", "SubVectors", "(", "a", ",", "b", "*", "Vector", ")", "*", "Vector", "{", "return", "NewVector", "(", "a", ".", "x", "-", "b", ".", "x", ",", "a", ".", "y", "-", "b", ".", "y", ")", "\n", "}" ]
// SubVectors returns a new vector as subtraction of two vectors.
[ "SubVectors", "returns", "a", "new", "vector", "as", "subtraction", "of", "two", "vectors", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L238-L240
150,141
tideland/golib
numerics/numerics.go
ScaleVector
func ScaleVector(v *Vector, s float64) *Vector { return NewVector(v.x*s, v.y*s) }
go
func ScaleVector(v *Vector, s float64) *Vector { return NewVector(v.x*s, v.y*s) }
[ "func", "ScaleVector", "(", "v", "*", "Vector", ",", "s", "float64", ")", "*", "Vector", "{", "return", "NewVector", "(", "v", ".", "x", "*", "s", ",", "v", ".", "y", "*", "s", ")", "\n", "}" ]
// ScaleVector multiplies a vector with a float and returns // the new vector.
[ "ScaleVector", "multiplies", "a", "vector", "with", "a", "float", "and", "returns", "the", "new", "vector", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L244-L246
150,142
tideland/golib
numerics/numerics.go
NewPolynomialFunction
func NewPolynomialFunction(coefficients []float64) *PolynomialFunction { if len(coefficients) < 1 { return nil } pf := &PolynomialFunction{ coefficients: coefficients, } return pf }
go
func NewPolynomialFunction(coefficients []float64) *PolynomialFunction { if len(coefficients) < 1 { return nil } pf := &PolynomialFunction{ coefficients: coefficients, } return pf }
[ "func", "NewPolynomialFunction", "(", "coefficients", "[", "]", "float64", ")", "*", "PolynomialFunction", "{", "if", "len", "(", "coefficients", ")", "<", "1", "{", "return", "nil", "\n", "}", "\n", "pf", ":=", "&", "PolynomialFunction", "{", "coefficients"...
// NewPolynomialFunction creates a new polynomial function.
[ "NewPolynomialFunction", "creates", "a", "new", "polynomial", "function", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L279-L287
150,143
tideland/golib
numerics/numerics.go
Differentiate
func (pf PolynomialFunction) Differentiate() *PolynomialFunction { n := len(pf.coefficients) if n == 1 { return NewPolynomialFunction([]float64{0.0}) } newCoefficients := make([]float64, n-1) for i := n - 1; i > 0; i-- { newCoefficients[i-1] = float64(i) * pf.coefficients[i] } return NewPolynomialFunction(ne...
go
func (pf PolynomialFunction) Differentiate() *PolynomialFunction { n := len(pf.coefficients) if n == 1 { return NewPolynomialFunction([]float64{0.0}) } newCoefficients := make([]float64, n-1) for i := n - 1; i > 0; i-- { newCoefficients[i-1] = float64(i) * pf.coefficients[i] } return NewPolynomialFunction(ne...
[ "func", "(", "pf", "PolynomialFunction", ")", "Differentiate", "(", ")", "*", "PolynomialFunction", "{", "n", ":=", "len", "(", "pf", ".", "coefficients", ")", "\n", "if", "n", "==", "1", "{", "return", "NewPolynomialFunction", "(", "[", "]", "float64", ...
// Differentiate differentiates the polynomial and returns the // new polynomial.
[ "Differentiate", "differentiates", "the", "polynomial", "and", "returns", "the", "new", "polynomial", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L314-L324
150,144
tideland/golib
numerics/numerics.go
NewLeastSquaresFunction
func NewLeastSquaresFunction(points Points) *LeastSquaresFunction { lsf := new(LeastSquaresFunction) if points != nil { lsf.AppendPoints(points) } return lsf }
go
func NewLeastSquaresFunction(points Points) *LeastSquaresFunction { lsf := new(LeastSquaresFunction) if points != nil { lsf.AppendPoints(points) } return lsf }
[ "func", "NewLeastSquaresFunction", "(", "points", "Points", ")", "*", "LeastSquaresFunction", "{", "lsf", ":=", "new", "(", "LeastSquaresFunction", ")", "\n", "if", "points", "!=", "nil", "{", "lsf", ".", "AppendPoints", "(", "points", ")", "\n", "}", "\n", ...
// NewLeastSquaresFunction creates a new least squares function based // on a set of points.
[ "NewLeastSquaresFunction", "creates", "a", "new", "least", "squares", "function", "based", "on", "a", "set", "of", "points", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L445-L451
150,145
tideland/golib
numerics/numerics.go
AppendPoint
func (lsf *LeastSquaresFunction) AppendPoint(x, y float64) { p := NewPoint(x, y) if lsf.count == 0 { lsf.xBar = p.X() lsf.yBar = p.Y() } else { dx := p.X() - lsf.xBar dy := p.Y() - lsf.yBar lsf.sumXX += dx * dx * float64(lsf.count) / float64(lsf.count+1.0) lsf.sumYY += dy * dy * float64(lsf.count) / flo...
go
func (lsf *LeastSquaresFunction) AppendPoint(x, y float64) { p := NewPoint(x, y) if lsf.count == 0 { lsf.xBar = p.X() lsf.yBar = p.Y() } else { dx := p.X() - lsf.xBar dy := p.Y() - lsf.yBar lsf.sumXX += dx * dx * float64(lsf.count) / float64(lsf.count+1.0) lsf.sumYY += dy * dy * float64(lsf.count) / flo...
[ "func", "(", "lsf", "*", "LeastSquaresFunction", ")", "AppendPoint", "(", "x", ",", "y", "float64", ")", "{", "p", ":=", "NewPoint", "(", "x", ",", "y", ")", "\n", "if", "lsf", ".", "count", "==", "0", "{", "lsf", ".", "xBar", "=", "p", ".", "X...
// AppendPoint appends one point to the function.
[ "AppendPoint", "appends", "one", "point", "to", "the", "function", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L454-L473
150,146
tideland/golib
numerics/numerics.go
AppendPoints
func (lsf *LeastSquaresFunction) AppendPoints(points Points) { for _, p := range points { lsf.AppendPoint(p.X(), p.Y()) } }
go
func (lsf *LeastSquaresFunction) AppendPoints(points Points) { for _, p := range points { lsf.AppendPoint(p.X(), p.Y()) } }
[ "func", "(", "lsf", "*", "LeastSquaresFunction", ")", "AppendPoints", "(", "points", "Points", ")", "{", "for", "_", ",", "p", ":=", "range", "points", "{", "lsf", ".", "AppendPoint", "(", "p", ".", "X", "(", ")", ",", "p", ".", "Y", "(", ")", ")...
// AppendPoints appends a set of points to the function.
[ "AppendPoints", "appends", "a", "set", "of", "points", "to", "the", "function", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L476-L480
150,147
tideland/golib
numerics/numerics.go
slope
func (lsf *LeastSquaresFunction) slope() float64 { if lsf.count < 2 { // Not enough points added. return math.NaN() } if math.Abs(lsf.sumXX) < 10*math.SmallestNonzeroFloat64 { // Not enough variation in X. return math.NaN() } return lsf.sumXY / lsf.sumXX }
go
func (lsf *LeastSquaresFunction) slope() float64 { if lsf.count < 2 { // Not enough points added. return math.NaN() } if math.Abs(lsf.sumXX) < 10*math.SmallestNonzeroFloat64 { // Not enough variation in X. return math.NaN() } return lsf.sumXY / lsf.sumXX }
[ "func", "(", "lsf", "*", "LeastSquaresFunction", ")", "slope", "(", ")", "float64", "{", "if", "lsf", ".", "count", "<", "2", "{", "// Not enough points added.", "return", "math", ".", "NaN", "(", ")", "\n", "}", "\n\n", "if", "math", ".", "Abs", "(", ...
// slope returns the slope of the least square function.
[ "slope", "returns", "the", "slope", "of", "the", "least", "square", "function", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L503-L514
150,148
tideland/golib
numerics/numerics.go
intercept
func (lsf *LeastSquaresFunction) intercept(slope float64) float64 { return (lsf.sumY - slope*lsf.sumX) / float64(lsf.count) }
go
func (lsf *LeastSquaresFunction) intercept(slope float64) float64 { return (lsf.sumY - slope*lsf.sumX) / float64(lsf.count) }
[ "func", "(", "lsf", "*", "LeastSquaresFunction", ")", "intercept", "(", "slope", "float64", ")", "float64", "{", "return", "(", "lsf", ".", "sumY", "-", "slope", "*", "lsf", ".", "sumX", ")", "/", "float64", "(", "lsf", ".", "count", ")", "\n", "}" ]
// intercept returns the intercept for a given slope.
[ "intercept", "returns", "the", "intercept", "for", "a", "given", "slope", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/numerics/numerics.go#L517-L519
150,149
tideland/golib
gjp/gjp.go
Parse
func Parse(data []byte, separator string) (Document, error) { var root interface{} err := json.Unmarshal(data, &root) if err != nil { return nil, errors.Annotate(err, ErrUnmarshalling, errorMessages) } return &document{ separator: separator, root: root, }, nil }
go
func Parse(data []byte, separator string) (Document, error) { var root interface{} err := json.Unmarshal(data, &root) if err != nil { return nil, errors.Annotate(err, ErrUnmarshalling, errorMessages) } return &document{ separator: separator, root: root, }, nil }
[ "func", "Parse", "(", "data", "[", "]", "byte", ",", "separator", "string", ")", "(", "Document", ",", "error", ")", "{", "var", "root", "interface", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "root", ")", "\n", ...
// Parse reads a raw document and returns it as // accessible document.
[ "Parse", "reads", "a", "raw", "document", "and", "returns", "it", "as", "accessible", "document", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/gjp.go#L71-L81
150,150
tideland/golib
gjp/gjp.go
Length
func (d *document) Length(path string) int { n, err := valueAt(d.root, splitPath(path, d.separator)) if err != nil { return -1 } // Check if object or array. o, ok := isObject(n) if ok { return len(o) } a, ok := isArray(n) if ok { return len(a) } return 1 }
go
func (d *document) Length(path string) int { n, err := valueAt(d.root, splitPath(path, d.separator)) if err != nil { return -1 } // Check if object or array. o, ok := isObject(n) if ok { return len(o) } a, ok := isArray(n) if ok { return len(a) } return 1 }
[ "func", "(", "d", "*", "document", ")", "Length", "(", "path", "string", ")", "int", "{", "n", ",", "err", ":=", "valueAt", "(", "d", ".", "root", ",", "splitPath", "(", "path", ",", "d", ".", "separator", ")", ")", "\n", "if", "err", "!=", "ni...
// Length implements Document.
[ "Length", "implements", "Document", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/gjp.go#L91-L106
150,151
tideland/golib
gjp/gjp.go
SetValueAt
func (d *document) SetValueAt(path string, value interface{}) error { parts := splitPath(path, d.separator) root, err := setValueAt(d.root, value, parts) if err != nil { return err } d.root = root return nil }
go
func (d *document) SetValueAt(path string, value interface{}) error { parts := splitPath(path, d.separator) root, err := setValueAt(d.root, value, parts) if err != nil { return err } d.root = root return nil }
[ "func", "(", "d", "*", "document", ")", "SetValueAt", "(", "path", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "parts", ":=", "splitPath", "(", "path", ",", "d", ".", "separator", ")", "\n", "root", ",", "err", ":=", "setValueAt...
// SetValueAt implements Document.
[ "SetValueAt", "implements", "Document", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/gjp.go#L109-L117
150,152
tideland/golib
gjp/gjp.go
ValueAt
func (d *document) ValueAt(path string) Value { n, err := valueAt(d.root, splitPath(path, d.separator)) return &value{n, err} }
go
func (d *document) ValueAt(path string) Value { n, err := valueAt(d.root, splitPath(path, d.separator)) return &value{n, err} }
[ "func", "(", "d", "*", "document", ")", "ValueAt", "(", "path", "string", ")", "Value", "{", "n", ",", "err", ":=", "valueAt", "(", "d", ".", "root", ",", "splitPath", "(", "path", ",", "d", ".", "separator", ")", ")", "\n", "return", "&", "value...
// ValueAt implements Document.
[ "ValueAt", "implements", "Document", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/gjp.go#L120-L123
150,153
tideland/golib
gjp/gjp.go
Query
func (d *document) Query(pattern string) (PathValues, error) { pvs := PathValues{} err := d.Process(func(path string, value Value) error { if stringex.Matches(pattern, path, false) { pvs = append(pvs, PathValue{ Path: path, Value: value, }) } return nil }) return pvs, err }
go
func (d *document) Query(pattern string) (PathValues, error) { pvs := PathValues{} err := d.Process(func(path string, value Value) error { if stringex.Matches(pattern, path, false) { pvs = append(pvs, PathValue{ Path: path, Value: value, }) } return nil }) return pvs, err }
[ "func", "(", "d", "*", "document", ")", "Query", "(", "pattern", "string", ")", "(", "PathValues", ",", "error", ")", "{", "pvs", ":=", "PathValues", "{", "}", "\n", "err", ":=", "d", ".", "Process", "(", "func", "(", "path", "string", ",", "value"...
// Query implements Document.
[ "Query", "implements", "Document", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/gjp.go#L131-L143
150,154
tideland/golib
gjp/gjp.go
Process
func (d *document) Process(processor ValueProcessor) error { return process(d.root, []string{}, d.separator, processor) }
go
func (d *document) Process(processor ValueProcessor) error { return process(d.root, []string{}, d.separator, processor) }
[ "func", "(", "d", "*", "document", ")", "Process", "(", "processor", "ValueProcessor", ")", "error", "{", "return", "process", "(", "d", ".", "root", ",", "[", "]", "string", "{", "}", ",", "d", ".", "separator", ",", "processor", ")", "\n", "}" ]
// Process implements Document.
[ "Process", "implements", "Document", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/gjp/gjp.go#L146-L148
150,155
tideland/golib
timex/crontab.go
NewCrontab
func NewCrontab(freq time.Duration) *Crontab { c := &Crontab{ frequency: freq, jobs: make(map[string]Job), commandChan: make(chan *command), } c.loop = loop.GoRecoverable(c.backendLoop, c.checkRecovering, "crontab", freq.String()) return c }
go
func NewCrontab(freq time.Duration) *Crontab { c := &Crontab{ frequency: freq, jobs: make(map[string]Job), commandChan: make(chan *command), } c.loop = loop.GoRecoverable(c.backendLoop, c.checkRecovering, "crontab", freq.String()) return c }
[ "func", "NewCrontab", "(", "freq", "time", ".", "Duration", ")", "*", "Crontab", "{", "c", ":=", "&", "Crontab", "{", "frequency", ":", "freq", ",", "jobs", ":", "make", "(", "map", "[", "string", "]", "Job", ")", ",", "commandChan", ":", "make", "...
// NewCrontab creates a cron server.
[ "NewCrontab", "creates", "a", "cron", "server", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/crontab.go#L54-L62
150,156
tideland/golib
timex/crontab.go
Add
func (c *Crontab) Add(id string, job Job) { c.commandChan <- &command{true, id, job} }
go
func (c *Crontab) Add(id string, job Job) { c.commandChan <- &command{true, id, job} }
[ "func", "(", "c", "*", "Crontab", ")", "Add", "(", "id", "string", ",", "job", "Job", ")", "{", "c", ".", "commandChan", "<-", "&", "command", "{", "true", ",", "id", ",", "job", "}", "\n", "}" ]
// Add adds a new job to the server.
[ "Add", "adds", "a", "new", "job", "to", "the", "server", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/crontab.go#L70-L72
150,157
tideland/golib
timex/crontab.go
Remove
func (c *Crontab) Remove(id string) { c.commandChan <- &command{false, id, nil} }
go
func (c *Crontab) Remove(id string) { c.commandChan <- &command{false, id, nil} }
[ "func", "(", "c", "*", "Crontab", ")", "Remove", "(", "id", "string", ")", "{", "c", ".", "commandChan", "<-", "&", "command", "{", "false", ",", "id", ",", "nil", "}", "\n", "}" ]
// Remove removes a job from the server.
[ "Remove", "removes", "a", "job", "from", "the", "server", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/crontab.go#L75-L77
150,158
tideland/golib
timex/crontab.go
backendLoop
func (c *Crontab) backendLoop(l loop.Loop) error { ticker := time.NewTicker(c.frequency) for { select { case <-l.ShallStop(): return nil case cmd := <-c.commandChan: if cmd.add { c.jobs[cmd.id] = cmd.job } else { delete(c.jobs, cmd.id) } case now := <-ticker.C: for id, job := range c.jo...
go
func (c *Crontab) backendLoop(l loop.Loop) error { ticker := time.NewTicker(c.frequency) for { select { case <-l.ShallStop(): return nil case cmd := <-c.commandChan: if cmd.add { c.jobs[cmd.id] = cmd.job } else { delete(c.jobs, cmd.id) } case now := <-ticker.C: for id, job := range c.jo...
[ "func", "(", "c", "*", "Crontab", ")", "backendLoop", "(", "l", "loop", ".", "Loop", ")", "error", "{", "ticker", ":=", "time", ".", "NewTicker", "(", "c", ".", "frequency", ")", "\n", "for", "{", "select", "{", "case", "<-", "l", ".", "ShallStop",...
// backendLoop runs the server backend.
[ "backendLoop", "runs", "the", "server", "backend", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/crontab.go#L80-L98
150,159
tideland/golib
timex/crontab.go
do
func (c *Crontab) do(id string, job Job, now time.Time) { if job.ShallExecute(now) { go func() { cont, err := job.Execute() if err != nil { logger.Errorf("job %q removed after error: %v", id, err) cont = false } if !cont { c.Remove(id) } }() } }
go
func (c *Crontab) do(id string, job Job, now time.Time) { if job.ShallExecute(now) { go func() { cont, err := job.Execute() if err != nil { logger.Errorf("job %q removed after error: %v", id, err) cont = false } if !cont { c.Remove(id) } }() } }
[ "func", "(", "c", "*", "Crontab", ")", "do", "(", "id", "string", ",", "job", "Job", ",", "now", "time", ".", "Time", ")", "{", "if", "job", ".", "ShallExecute", "(", "now", ")", "{", "go", "func", "(", ")", "{", "cont", ",", "err", ":=", "jo...
// do checks and performs a job.
[ "do", "checks", "and", "performs", "a", "job", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/timex/crontab.go#L111-L124
150,160
tideland/golib
audit/printer.go
ValueDescription
func ValueDescription(value interface{}) string { rvalue := reflect.ValueOf(value) kind := rvalue.Kind() switch kind { case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: return kind.String() + " of " + rvalue.Type().Elem().String() case reflect.Func: return kind.String() + " " + rvalue.Type().Name()...
go
func ValueDescription(value interface{}) string { rvalue := reflect.ValueOf(value) kind := rvalue.Kind() switch kind { case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: return kind.String() + " of " + rvalue.Type().Elem().String() case reflect.Func: return kind.String() + " " + rvalue.Type().Name()...
[ "func", "ValueDescription", "(", "value", "interface", "{", "}", ")", "string", "{", "rvalue", ":=", "reflect", ".", "ValueOf", "(", "value", ")", "\n", "kind", ":=", "rvalue", ".", "Kind", "(", ")", "\n", "switch", "kind", "{", "case", "reflect", ".",...
// ValueDescription returns a description of a value as string.
[ "ValueDescription", "returns", "a", "description", "of", "a", "value", "as", "string", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/printer.go#L60-L75
150,161
tideland/golib
audit/printer.go
Printf
func (p *fmtPrinter) Printf(format string, args ...interface{}) { fmt.Printf(format, args...) }
go
func (p *fmtPrinter) Printf(format string, args ...interface{}) { fmt.Printf(format, args...) }
[ "func", "(", "p", "*", "fmtPrinter", ")", "Printf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "fmt", ".", "Printf", "(", "format", ",", "args", "...", ")", "\n", "}" ]
// Printf implements the Printer interface.
[ "Printf", "implements", "the", "Printer", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/printer.go#L94-L96
150,162
tideland/golib
audit/printer.go
SetPrinter
func SetPrinter(p Printer) Printer { mux.Lock() defer mux.Unlock() cp := printerBackend printerBackend = p return cp }
go
func SetPrinter(p Printer) Printer { mux.Lock() defer mux.Unlock() cp := printerBackend printerBackend = p return cp }
[ "func", "SetPrinter", "(", "p", "Printer", ")", "Printer", "{", "mux", ".", "Lock", "(", ")", "\n", "defer", "mux", ".", "Unlock", "(", ")", "\n", "cp", ":=", "printerBackend", "\n", "printerBackend", "=", "p", "\n", "return", "cp", "\n", "}" ]
// SetPrinter sets a new global printer and returns the // current one.
[ "SetPrinter", "sets", "a", "new", "global", "printer", "and", "returns", "the", "current", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/printer.go#L100-L106
150,163
tideland/golib
audit/printer.go
backendPrintf
func backendPrintf(format string, args ...interface{}) { mux.Lock() defer mux.Unlock() printerBackend.Printf(format, args...) }
go
func backendPrintf(format string, args ...interface{}) { mux.Lock() defer mux.Unlock() printerBackend.Printf(format, args...) }
[ "func", "backendPrintf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "mux", ".", "Lock", "(", ")", "\n", "defer", "mux", ".", "Unlock", "(", ")", "\n", "printerBackend", ".", "Printf", "(", "format", ",", "args", ".....
// backendPrintf uses the printer backend for output. It is used // in the types below.
[ "backendPrintf", "uses", "the", "printer", "backend", "for", "output", ".", "It", "is", "used", "in", "the", "types", "below", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/audit/printer.go#L110-L114
150,164
tideland/golib
loop/loop.go
GoRecoverable
func GoRecoverable(lf LoopFunc, rf RecoverFunc, dps ...interface{}) Loop { descr := identifier.SepIdentifier("::", dps...) return goLoop(lf, rf, nil, nil, descr) }
go
func GoRecoverable(lf LoopFunc, rf RecoverFunc, dps ...interface{}) Loop { descr := identifier.SepIdentifier("::", dps...) return goLoop(lf, rf, nil, nil, descr) }
[ "func", "GoRecoverable", "(", "lf", "LoopFunc", ",", "rf", "RecoverFunc", ",", "dps", "...", "interface", "{", "}", ")", "Loop", "{", "descr", ":=", "identifier", ".", "SepIdentifier", "(", "\"", "\"", ",", "dps", "...", ")", "\n", "return", "goLoop", ...
// GoRecoverable starts the loop function in the background. The // loop can be stopped or killed. This leads to a signal out of the // channel Loop.ShallStop. The loop then has to end working returning // a possible error. Wait then waits until the loop ended and returns // the error. // // If the loop panics a Recove...
[ "GoRecoverable", "starts", "the", "loop", "function", "in", "the", "background", ".", "The", "loop", "can", "be", "stopped", "or", "killed", ".", "This", "leads", "to", "a", "signal", "out", "of", "the", "channel", "Loop", ".", "ShallStop", ".", "The", "...
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L48-L51
150,165
tideland/golib
loop/loop.go
GoSentinel
func GoSentinel(dps ...interface{}) Sentinel { descr := identifier.SepIdentifier("::", dps...) return goSentinel(nil, nil, descr) }
go
func GoSentinel(dps ...interface{}) Sentinel { descr := identifier.SepIdentifier("::", dps...) return goSentinel(nil, nil, descr) }
[ "func", "GoSentinel", "(", "dps", "...", "interface", "{", "}", ")", "Sentinel", "{", "descr", ":=", "identifier", ".", "SepIdentifier", "(", "\"", "\"", ",", "dps", "...", ")", "\n", "return", "goSentinel", "(", "nil", ",", "nil", ",", "descr", ")", ...
// GoSentinel starts a new sentinel. It can manage loops and other sentinels // and will stop them in case of errors.
[ "GoSentinel", "starts", "a", "new", "sentinel", ".", "It", "can", "manage", "loops", "and", "other", "sentinels", "and", "will", "stop", "them", "in", "case", "of", "errors", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L55-L58
150,166
tideland/golib
loop/loop.go
GoNotifiedSentinel
func GoNotifiedSentinel(nhf NotificationHandlerFunc, dps ...interface{}) Sentinel { descr := identifier.SepIdentifier("::", dps...) return goSentinel(nhf, nil, descr) }
go
func GoNotifiedSentinel(nhf NotificationHandlerFunc, dps ...interface{}) Sentinel { descr := identifier.SepIdentifier("::", dps...) return goSentinel(nhf, nil, descr) }
[ "func", "GoNotifiedSentinel", "(", "nhf", "NotificationHandlerFunc", ",", "dps", "...", "interface", "{", "}", ")", "Sentinel", "{", "descr", ":=", "identifier", ".", "SepIdentifier", "(", "\"", "\"", ",", "dps", "...", ")", "\n", "return", "goSentinel", "("...
// GoNotifiedSentinel starts a new sentinel with a notification handler // function. It can manage loops and other sentinels and restart them in // case of errors, based on the notification handler function.
[ "GoNotifiedSentinel", "starts", "a", "new", "sentinel", "with", "a", "notification", "handler", "function", ".", "It", "can", "manage", "loops", "and", "other", "sentinels", "and", "restart", "them", "in", "case", "of", "errors", "based", "on", "the", "notific...
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L63-L66
150,167
tideland/golib
loop/loop.go
Frequency
func (rs Recoverings) Frequency(num int, dur time.Duration) bool { if len(rs) >= num { first := rs[len(rs)-num].Time last := rs[len(rs)-1].Time return last.Sub(first) <= dur } return false }
go
func (rs Recoverings) Frequency(num int, dur time.Duration) bool { if len(rs) >= num { first := rs[len(rs)-num].Time last := rs[len(rs)-1].Time return last.Sub(first) <= dur } return false }
[ "func", "(", "rs", "Recoverings", ")", "Frequency", "(", "num", "int", ",", "dur", "time", ".", "Duration", ")", "bool", "{", "if", "len", "(", "rs", ")", ">=", "num", "{", "first", ":=", "rs", "[", "len", "(", "rs", ")", "-", "num", "]", ".", ...
// Frequency checks if a given number of restarts happened during // a given duration.
[ "Frequency", "checks", "if", "a", "given", "number", "of", "restarts", "happened", "during", "a", "given", "duration", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L83-L90
150,168
tideland/golib
loop/loop.go
Trim
func (rs Recoverings) Trim(l int) Recoverings { if l >= len(rs) { return rs } return rs[len(rs)-l:] }
go
func (rs Recoverings) Trim(l int) Recoverings { if l >= len(rs) { return rs } return rs[len(rs)-l:] }
[ "func", "(", "rs", "Recoverings", ")", "Trim", "(", "l", "int", ")", "Recoverings", "{", "if", "l", ">=", "len", "(", "rs", ")", "{", "return", "rs", "\n", "}", "\n", "return", "rs", "[", "len", "(", "rs", ")", "-", "l", ":", "]", "\n", "}" ]
// Trim returns the last recoverings defined by l. This // way the recover func can con control the length and take // care that the list not grows too much.
[ "Trim", "returns", "the", "last", "recoverings", "defined", "by", "l", ".", "This", "way", "the", "recover", "func", "can", "con", "control", "the", "length", "and", "take", "care", "that", "the", "list", "not", "grows", "too", "much", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L100-L105
150,169
tideland/golib
loop/loop.go
Last
func (rs Recoverings) Last() *Recovering { if len(rs) > 0 { return rs[len(rs)-1] } return nil }
go
func (rs Recoverings) Last() *Recovering { if len(rs) > 0 { return rs[len(rs)-1] } return nil }
[ "func", "(", "rs", "Recoverings", ")", "Last", "(", ")", "*", "Recovering", "{", "if", "len", "(", "rs", ")", ">", "0", "{", "return", "rs", "[", "len", "(", "rs", ")", "-", "1", "]", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Last returns the last recovering.
[ "Last", "returns", "the", "last", "recovering", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L116-L121
150,170
tideland/golib
loop/loop.go
goLoop
func goLoop(lf LoopFunc, rf RecoverFunc, o Observable, s *sentinel, d string) *loop { l := &loop{ descr: d, loopF: lf, recoverF: rf, startedC: make(chan struct{}), stopC: make(chan struct{}), doneC: make(chan struct{}), owner: o, sentinel: s, } // Check owner, at least we should own ou...
go
func goLoop(lf LoopFunc, rf RecoverFunc, o Observable, s *sentinel, d string) *loop { l := &loop{ descr: d, loopF: lf, recoverF: rf, startedC: make(chan struct{}), stopC: make(chan struct{}), doneC: make(chan struct{}), owner: o, sentinel: s, } // Check owner, at least we should own ou...
[ "func", "goLoop", "(", "lf", "LoopFunc", ",", "rf", "RecoverFunc", ",", "o", "Observable", ",", "s", "*", "sentinel", ",", "d", "string", ")", "*", "loop", "{", "l", ":=", "&", "loop", "{", "descr", ":", "d", ",", "loopF", ":", "lf", ",", "recove...
// goLoop starts a loop in the background.
[ "goLoop", "starts", "a", "loop", "in", "the", "background", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L202-L222
150,171
tideland/golib
loop/loop.go
Wait
func (l *loop) Wait() error { <-l.doneC l.mux.Lock() defer l.mux.Unlock() err := l.err return err }
go
func (l *loop) Wait() error { <-l.doneC l.mux.Lock() defer l.mux.Unlock() err := l.err return err }
[ "func", "(", "l", "*", "loop", ")", "Wait", "(", ")", "error", "{", "<-", "l", ".", "doneC", "\n", "l", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mux", ".", "Unlock", "(", ")", "\n", "err", ":=", "l", ".", "err", "\n", ...
// Wait implements the Observable interface.
[ "Wait", "implements", "the", "Observable", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L242-L248
150,172
tideland/golib
loop/loop.go
Error
func (l *loop) Error() (status int, err error) { l.mux.Lock() defer l.mux.Unlock() status = l.status err = l.err return }
go
func (l *loop) Error() (status int, err error) { l.mux.Lock() defer l.mux.Unlock() status = l.status err = l.err return }
[ "func", "(", "l", "*", "loop", ")", "Error", "(", ")", "(", "status", "int", ",", "err", "error", ")", "{", "l", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mux", ".", "Unlock", "(", ")", "\n", "status", "=", "l", ".", "sta...
// Error implements the Observable interface.
[ "Error", "implements", "the", "Observable", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L270-L276
150,173
tideland/golib
loop/loop.go
attachSentinel
func (l *loop) attachSentinel(s *sentinel) { l.mux.Lock() defer l.mux.Unlock() if l.sentinel != nil { l.sentinel.Forget(l) } l.sentinel = s }
go
func (l *loop) attachSentinel(s *sentinel) { l.mux.Lock() defer l.mux.Unlock() if l.sentinel != nil { l.sentinel.Forget(l) } l.sentinel = s }
[ "func", "(", "l", "*", "loop", ")", "attachSentinel", "(", "s", "*", "sentinel", ")", "{", "l", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mux", ".", "Unlock", "(", ")", "\n", "if", "l", ".", "sentinel", "!=", "nil", "{", "l...
// attachSentinel implements the Observable interface.
[ "attachSentinel", "implements", "the", "Observable", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L279-L286
150,174
tideland/golib
loop/loop.go
run
func (l *loop) run() { l.status = Running // Finalize the loop. defer l.finalizeTermination() // Create a loop wrapper containing the recovering control. loopWrapper := func() { defer func() { // Check for recovering. if reason := recover(); reason != nil { l.checkTermination(reason) } }() l.che...
go
func (l *loop) run() { l.status = Running // Finalize the loop. defer l.finalizeTermination() // Create a loop wrapper containing the recovering control. loopWrapper := func() { defer func() { // Check for recovering. if reason := recover(); reason != nil { l.checkTermination(reason) } }() l.che...
[ "func", "(", "l", "*", "loop", ")", "run", "(", ")", "{", "l", ".", "status", "=", "Running", "\n", "// Finalize the loop.", "defer", "l", ".", "finalizeTermination", "(", ")", "\n", "// Create a loop wrapper containing the recovering control.", "loopWrapper", ":=...
// run operates the loop as goroutine.
[ "run", "operates", "the", "loop", "as", "goroutine", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L299-L318
150,175
tideland/golib
loop/loop.go
terminate
func (l *loop) terminate(err error) { l.mux.Lock() defer l.mux.Unlock() if l.err == nil { l.err = err } if l.status != Running { return } l.status = Stopping select { case <-l.stopC: default: close(l.stopC) } }
go
func (l *loop) terminate(err error) { l.mux.Lock() defer l.mux.Unlock() if l.err == nil { l.err = err } if l.status != Running { return } l.status = Stopping select { case <-l.stopC: default: close(l.stopC) } }
[ "func", "(", "l", "*", "loop", ")", "terminate", "(", "err", "error", ")", "{", "l", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mux", ".", "Unlock", "(", ")", "\n", "if", "l", ".", "err", "==", "nil", "{", "l", ".", "err",...
// terminate tells the loop to stop working and stores // the passed error if none has been stored already.
[ "terminate", "tells", "the", "loop", "to", "stop", "working", "and", "stores", "the", "passed", "error", "if", "none", "has", "been", "stored", "already", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L322-L337
150,176
tideland/golib
loop/loop.go
checkTermination
func (l *loop) checkTermination(reason interface{}) { switch { case reason == nil: // Regular end. l.status = Stopping case l.recoverF == nil: // Error but no recover function. l.status = Stopping if l.err != nil { break } if err, ok := reason.(error); ok { l.err = err } else { l.err = error...
go
func (l *loop) checkTermination(reason interface{}) { switch { case reason == nil: // Regular end. l.status = Stopping case l.recoverF == nil: // Error but no recover function. l.status = Stopping if l.err != nil { break } if err, ok := reason.(error); ok { l.err = err } else { l.err = error...
[ "func", "(", "l", "*", "loop", ")", "checkTermination", "(", "reason", "interface", "{", "}", ")", "{", "switch", "{", "case", "reason", "==", "nil", ":", "// Regular end.", "l", ".", "status", "=", "Stopping", "\n", "case", "l", ".", "recoverF", "==",...
// checkTermination checks if an error has been the reason and if // it possibly can be recovered by a recover function.
[ "checkTermination", "checks", "if", "an", "error", "has", "been", "the", "reason", "and", "if", "it", "possibly", "can", "be", "recovered", "by", "a", "recover", "function", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L341-L368
150,177
tideland/golib
loop/loop.go
finalizeTermination
func (l *loop) finalizeTermination() { l.status = Stopped // Close stopC in case the termination is due to an // error or internal. select { case <-l.stopC: default: close(l.stopC) } // Communicate that it's done. select { case <-l.doneC: default: close(l.doneC) } // If a sentinel monitors us then til...
go
func (l *loop) finalizeTermination() { l.status = Stopped // Close stopC in case the termination is due to an // error or internal. select { case <-l.stopC: default: close(l.stopC) } // Communicate that it's done. select { case <-l.doneC: default: close(l.doneC) } // If a sentinel monitors us then til...
[ "func", "(", "l", "*", "loop", ")", "finalizeTermination", "(", ")", "{", "l", ".", "status", "=", "Stopped", "\n", "// Close stopC in case the termination is due to an", "// error or internal.", "select", "{", "case", "<-", "l", ".", "stopC", ":", "default", "...
// finalizeTermination notifies listeners that the loop stopped // working and a potential sentinal about its status.
[ "finalizeTermination", "notifies", "listeners", "that", "the", "loop", "stopped", "working", "and", "a", "potential", "sentinal", "about", "its", "status", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L372-L402
150,178
tideland/golib
loop/loop.go
logf
func (l *loop) logf(isError bool, format string, a ...interface{}) { if l.descr == "" { return } if isError { logger.Errorf(format, a...) } else { logger.Infof(format, a...) } }
go
func (l *loop) logf(isError bool, format string, a ...interface{}) { if l.descr == "" { return } if isError { logger.Errorf(format, a...) } else { logger.Infof(format, a...) } }
[ "func", "(", "l", "*", "loop", ")", "logf", "(", "isError", "bool", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "if", "l", ".", "descr", "==", "\"", "\"", "{", "return", "\n", "}", "\n", "if", "isError", "{", "log...
// log writes information or error only if the loop has a description.
[ "log", "writes", "information", "or", "error", "only", "if", "the", "loop", "has", "a", "description", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/loop/loop.go#L405-L414
150,179
tideland/golib
collections/stacks.go
Push
func (s *stack) Push(vs ...interface{}) { s.values = append(s.values, vs...) }
go
func (s *stack) Push(vs ...interface{}) { s.values = append(s.values, vs...) }
[ "func", "(", "s", "*", "stack", ")", "Push", "(", "vs", "...", "interface", "{", "}", ")", "{", "s", ".", "values", "=", "append", "(", "s", ".", "values", ",", "vs", "...", ")", "\n", "}" ]
// Push implements the Stack interface.
[ "Push", "implements", "the", "Stack", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/stacks.go#L38-L40
150,180
tideland/golib
collections/stacks.go
Pop
func (s *stack) Pop() (interface{}, error) { lv := len(s.values) if lv == 0 { return nil, errors.New(ErrEmpty, errorMessages) } v := s.values[lv-1] s.values = s.values[:lv-1] return v, nil }
go
func (s *stack) Pop() (interface{}, error) { lv := len(s.values) if lv == 0 { return nil, errors.New(ErrEmpty, errorMessages) } v := s.values[lv-1] s.values = s.values[:lv-1] return v, nil }
[ "func", "(", "s", "*", "stack", ")", "Pop", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "lv", ":=", "len", "(", "s", ".", "values", ")", "\n", "if", "lv", "==", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "E...
// Pop implements the Stack interface.
[ "Pop", "implements", "the", "Stack", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/stacks.go#L43-L51
150,181
tideland/golib
collections/stacks.go
All
func (s *stack) All() []interface{} { sl := len(s.values) all := make([]interface{}, sl) copy(all, s.values) return all }
go
func (s *stack) All() []interface{} { sl := len(s.values) all := make([]interface{}, sl) copy(all, s.values) return all }
[ "func", "(", "s", "*", "stack", ")", "All", "(", ")", "[", "]", "interface", "{", "}", "{", "sl", ":=", "len", "(", "s", ".", "values", ")", "\n", "all", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "sl", ")", "\n", "copy", "(",...
// All implements the Stack interface.
[ "All", "implements", "the", "Stack", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/stacks.go#L64-L69
150,182
tideland/golib
collections/stacks.go
AllReverse
func (s *stack) AllReverse() []interface{} { sl := len(s.values) all := make([]interface{}, sl) for i, value := range s.values { all[sl-1-i] = value } return all }
go
func (s *stack) AllReverse() []interface{} { sl := len(s.values) all := make([]interface{}, sl) for i, value := range s.values { all[sl-1-i] = value } return all }
[ "func", "(", "s", "*", "stack", ")", "AllReverse", "(", ")", "[", "]", "interface", "{", "}", "{", "sl", ":=", "len", "(", "s", ".", "values", ")", "\n", "all", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "sl", ")", "\n", "for", ...
// AllReverse implements the Stack interface.
[ "AllReverse", "implements", "the", "Stack", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/stacks.go#L72-L79
150,183
tideland/golib
collections/stacks.go
Push
func (s *stringStack) Push(vs ...string) { s.values = append(s.values, vs...) }
go
func (s *stringStack) Push(vs ...string) { s.values = append(s.values, vs...) }
[ "func", "(", "s", "*", "stringStack", ")", "Push", "(", "vs", "...", "string", ")", "{", "s", ".", "values", "=", "append", "(", "s", ".", "values", ",", "vs", "...", ")", "\n", "}" ]
// Push implements the StringStack interface.
[ "Push", "implements", "the", "StringStack", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/stacks.go#L114-L116
150,184
tideland/golib
collections/stacks.go
All
func (s *stringStack) All() []string { sl := len(s.values) all := make([]string, sl) copy(all, s.values) return all }
go
func (s *stringStack) All() []string { sl := len(s.values) all := make([]string, sl) copy(all, s.values) return all }
[ "func", "(", "s", "*", "stringStack", ")", "All", "(", ")", "[", "]", "string", "{", "sl", ":=", "len", "(", "s", ".", "values", ")", "\n", "all", ":=", "make", "(", "[", "]", "string", ",", "sl", ")", "\n", "copy", "(", "all", ",", "s", "....
// All implements the StringStack interface.
[ "All", "implements", "the", "StringStack", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/stacks.go#L140-L145
150,185
tideland/golib
collections/stacks.go
AllReverse
func (s *stringStack) AllReverse() []string { sl := len(s.values) all := make([]string, sl) for i, value := range s.values { all[sl-1-i] = value } return all }
go
func (s *stringStack) AllReverse() []string { sl := len(s.values) all := make([]string, sl) for i, value := range s.values { all[sl-1-i] = value } return all }
[ "func", "(", "s", "*", "stringStack", ")", "AllReverse", "(", ")", "[", "]", "string", "{", "sl", ":=", "len", "(", "s", ".", "values", ")", "\n", "all", ":=", "make", "(", "[", "]", "string", ",", "sl", ")", "\n", "for", "i", ",", "value", "...
// AllReverse implements the StringStack interface.
[ "AllReverse", "implements", "the", "StringStack", "interface", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/collections/stacks.go#L148-L155
150,186
tideland/golib
sml/nodes.go
newTagNode
func newTagNode(tag string) (*tagNode, error) { vtag, err := ValidateTag(tag) if err != nil { return nil, err } return &tagNode{ tag: vtag, children: []Node{}, }, nil }
go
func newTagNode(tag string) (*tagNode, error) { vtag, err := ValidateTag(tag) if err != nil { return nil, err } return &tagNode{ tag: vtag, children: []Node{}, }, nil }
[ "func", "newTagNode", "(", "tag", "string", ")", "(", "*", "tagNode", ",", "error", ")", "{", "vtag", ",", "err", ":=", "ValidateTag", "(", "tag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "...
// newTagNode creates a node with the given tag.
[ "newTagNode", "creates", "a", "node", "with", "the", "given", "tag", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L33-L42
150,187
tideland/golib
sml/nodes.go
appendTagNode
func (tn *tagNode) appendTagNode(tag string) (*tagNode, error) { ntn, err := newTagNode(tag) if err != nil { return nil, err } tn.appendChild(ntn) return ntn, nil }
go
func (tn *tagNode) appendTagNode(tag string) (*tagNode, error) { ntn, err := newTagNode(tag) if err != nil { return nil, err } tn.appendChild(ntn) return ntn, nil }
[ "func", "(", "tn", "*", "tagNode", ")", "appendTagNode", "(", "tag", "string", ")", "(", "*", "tagNode", ",", "error", ")", "{", "ntn", ",", "err", ":=", "newTagNode", "(", "tag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "e...
// appendTagNode creates a new tag node, appends it as last child // and returns it.
[ "appendTagNode", "creates", "a", "new", "tag", "node", "appends", "it", "as", "last", "child", "and", "returns", "it", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L46-L53
150,188
tideland/golib
sml/nodes.go
appendTextNode
func (tn *tagNode) appendTextNode(text string) *textNode { trimmedText := strings.TrimSpace(text) if trimmedText == "" { return nil } ntn := newTextNode(trimmedText) tn.appendChild(ntn) return ntn }
go
func (tn *tagNode) appendTextNode(text string) *textNode { trimmedText := strings.TrimSpace(text) if trimmedText == "" { return nil } ntn := newTextNode(trimmedText) tn.appendChild(ntn) return ntn }
[ "func", "(", "tn", "*", "tagNode", ")", "appendTextNode", "(", "text", "string", ")", "*", "textNode", "{", "trimmedText", ":=", "strings", ".", "TrimSpace", "(", "text", ")", "\n", "if", "trimmedText", "==", "\"", "\"", "{", "return", "nil", "\n", "}"...
// appendTextNode creates a text node, appends it as last child // and returns it.
[ "appendTextNode", "creates", "a", "text", "node", "appends", "it", "as", "last", "child", "and", "returns", "it", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L57-L65
150,189
tideland/golib
sml/nodes.go
appendRawNode
func (tn *tagNode) appendRawNode(raw string) *rawNode { nrn := newRawNode(raw) tn.appendChild(nrn) return nrn }
go
func (tn *tagNode) appendRawNode(raw string) *rawNode { nrn := newRawNode(raw) tn.appendChild(nrn) return nrn }
[ "func", "(", "tn", "*", "tagNode", ")", "appendRawNode", "(", "raw", "string", ")", "*", "rawNode", "{", "nrn", ":=", "newRawNode", "(", "raw", ")", "\n", "tn", ".", "appendChild", "(", "nrn", ")", "\n", "return", "nrn", "\n", "}" ]
// appendRawNode creates a raw node, appends it as last child // and returns it.
[ "appendRawNode", "creates", "a", "raw", "node", "appends", "it", "as", "last", "child", "and", "returns", "it", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L69-L73
150,190
tideland/golib
sml/nodes.go
appendCommentNode
func (tn *tagNode) appendCommentNode(comment string) *commentNode { ncn := newCommentNode(comment) tn.appendChild(ncn) return ncn }
go
func (tn *tagNode) appendCommentNode(comment string) *commentNode { ncn := newCommentNode(comment) tn.appendChild(ncn) return ncn }
[ "func", "(", "tn", "*", "tagNode", ")", "appendCommentNode", "(", "comment", "string", ")", "*", "commentNode", "{", "ncn", ":=", "newCommentNode", "(", "comment", ")", "\n", "tn", ".", "appendChild", "(", "ncn", ")", "\n", "return", "ncn", "\n", "}" ]
// appendCommentNode creates a comment node, appends it as last child // and returns it.
[ "appendCommentNode", "creates", "a", "comment", "node", "appends", "it", "as", "last", "child", "and", "returns", "it", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L77-L81
150,191
tideland/golib
sml/nodes.go
appendChild
func (tn *tagNode) appendChild(n Node) { tn.children = append(tn.children, n) }
go
func (tn *tagNode) appendChild(n Node) { tn.children = append(tn.children, n) }
[ "func", "(", "tn", "*", "tagNode", ")", "appendChild", "(", "n", "Node", ")", "{", "tn", ".", "children", "=", "append", "(", "tn", ".", "children", ",", "n", ")", "\n", "}" ]
// appendChild adds a node as last child.
[ "appendChild", "adds", "a", "node", "as", "last", "child", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L84-L86
150,192
tideland/golib
sml/nodes.go
Tag
func (tn *tagNode) Tag() []string { out := make([]string, len(tn.tag)) copy(out, tn.tag) return out }
go
func (tn *tagNode) Tag() []string { out := make([]string, len(tn.tag)) copy(out, tn.tag) return out }
[ "func", "(", "tn", "*", "tagNode", ")", "Tag", "(", ")", "[", "]", "string", "{", "out", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "tn", ".", "tag", ")", ")", "\n", "copy", "(", "out", ",", "tn", ".", "tag", ")", "\n", "return...
// Tag returns the tag parts.
[ "Tag", "returns", "the", "tag", "parts", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L89-L93
150,193
tideland/golib
sml/nodes.go
ProcessWith
func (tn *tagNode) ProcessWith(p Processor) error { if err := p.OpenTag(tn.tag); err != nil { return err } for _, child := range tn.children { if err := child.ProcessWith(p); err != nil { return err } } return p.CloseTag(tn.tag) }
go
func (tn *tagNode) ProcessWith(p Processor) error { if err := p.OpenTag(tn.tag); err != nil { return err } for _, child := range tn.children { if err := child.ProcessWith(p); err != nil { return err } } return p.CloseTag(tn.tag) }
[ "func", "(", "tn", "*", "tagNode", ")", "ProcessWith", "(", "p", "Processor", ")", "error", "{", "if", "err", ":=", "p", ".", "OpenTag", "(", "tn", ".", "tag", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ","...
// ProcessWith processes the node and all chidlren recursively // with the passed processor.
[ "ProcessWith", "processes", "the", "node", "and", "all", "chidlren", "recursively", "with", "the", "passed", "processor", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L102-L112
150,194
tideland/golib
sml/nodes.go
String
func (tn *tagNode) String() string { var buf bytes.Buffer context := NewWriterContext(NewStandardSMLWriter(), &buf, true, "\t") WriteSML(tn, context) return buf.String() }
go
func (tn *tagNode) String() string { var buf bytes.Buffer context := NewWriterContext(NewStandardSMLWriter(), &buf, true, "\t") WriteSML(tn, context) return buf.String() }
[ "func", "(", "tn", "*", "tagNode", ")", "String", "(", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "context", ":=", "NewWriterContext", "(", "NewStandardSMLWriter", "(", ")", ",", "&", "buf", ",", "true", ",", "\"", "\\t", "\"", "...
// String returns the tag node as string.
[ "String", "returns", "the", "tag", "node", "as", "string", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L115-L120
150,195
tideland/golib
sml/nodes.go
ProcessWith
func (tn *textNode) ProcessWith(p Processor) error { return p.Text(tn.text) }
go
func (tn *textNode) ProcessWith(p Processor) error { return p.Text(tn.text) }
[ "func", "(", "tn", "*", "textNode", ")", "ProcessWith", "(", "p", "Processor", ")", "error", "{", "return", "p", ".", "Text", "(", "tn", ".", "text", ")", "\n", "}" ]
// ProcessWith processes the text node with the given // processor.
[ "ProcessWith", "processes", "the", "text", "node", "with", "the", "given", "processor", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L148-L150
150,196
tideland/golib
sml/nodes.go
ProcessWith
func (rn *rawNode) ProcessWith(p Processor) error { return p.Raw(rn.raw) }
go
func (rn *rawNode) ProcessWith(p Processor) error { return p.Raw(rn.raw) }
[ "func", "(", "rn", "*", "rawNode", ")", "ProcessWith", "(", "p", "Processor", ")", "error", "{", "return", "p", ".", "Raw", "(", "rn", ".", "raw", ")", "\n", "}" ]
// ProcessWith processes the raw node with the given // processor.
[ "ProcessWith", "processes", "the", "raw", "node", "with", "the", "given", "processor", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L183-L185
150,197
tideland/golib
sml/nodes.go
ProcessWith
func (cn *commentNode) ProcessWith(p Processor) error { return p.Comment(cn.comment) }
go
func (cn *commentNode) ProcessWith(p Processor) error { return p.Comment(cn.comment) }
[ "func", "(", "cn", "*", "commentNode", ")", "ProcessWith", "(", "p", "Processor", ")", "error", "{", "return", "p", ".", "Comment", "(", "cn", ".", "comment", ")", "\n", "}" ]
// ProcessWith processes the comment node with the given // processor.
[ "ProcessWith", "processes", "the", "comment", "node", "with", "the", "given", "processor", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L218-L220
150,198
tideland/golib
sml/nodes.go
init
func init() { var err error validTagRe, err = regexp.Compile(`^([a-z][a-z0-9]*(\-[a-z0-9]+)*)(:([a-z0-9]+(\-[a-z0-9]+)*))*$`) if err != nil { panic(err) } }
go
func init() { var err error validTagRe, err = regexp.Compile(`^([a-z][a-z0-9]*(\-[a-z0-9]+)*)(:([a-z0-9]+(\-[a-z0-9]+)*))*$`) if err != nil { panic(err) } }
[ "func", "init", "(", ")", "{", "var", "err", "error", "\n", "validTagRe", ",", "err", "=", "regexp", ".", "Compile", "(", "`^([a-z][a-z0-9]*(\\-[a-z0-9]+)*)(:([a-z0-9]+(\\-[a-z0-9]+)*))*$`", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", ...
// init the regexp for valid tags.
[ "init", "the", "regexp", "for", "valid", "tags", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/sml/nodes.go#L236-L242
150,199
tideland/golib
monitoring/monitoring.go
backend
func (m *monitoring) backend() Backend { if m.b == nil { m.b = NewStandardBackend() } return m.b }
go
func (m *monitoring) backend() Backend { if m.b == nil { m.b = NewStandardBackend() } return m.b }
[ "func", "(", "m", "*", "monitoring", ")", "backend", "(", ")", "Backend", "{", "if", "m", ".", "b", "==", "nil", "{", "m", ".", "b", "=", "NewStandardBackend", "(", ")", "\n", "}", "\n", "return", "m", ".", "b", "\n", "}" ]
// backend ensures, that a backend is set. By default // it's the standard one.
[ "backend", "ensures", "that", "a", "backend", "is", "set", ".", "By", "default", "it", "s", "the", "standard", "one", "." ]
b56169c6bd620eeb7cfc4b9b4027fc10d2934c84
https://github.com/tideland/golib/blob/b56169c6bd620eeb7cfc4b9b4027fc10d2934c84/monitoring/monitoring.go#L216-L221