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
142,100
gravitational/configure
schema/schema.go
Args
func (c *Config) Args() []string { args := []string{} for _, p := range c.Params { args = append(args, p.Args()...) } return args }
go
func (c *Config) Args() []string { args := []string{} for _, p := range c.Params { args = append(args, p.Args()...) } return args }
[ "func", "(", "c", "*", "Config", ")", "Args", "(", ")", "[", "]", "string", "{", "args", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "p", ":=", "range", "c", ".", "Params", "{", "args", "=", "append", "(", "args", ",", "p", "...
// Args returns the list of arguments for all parameters
[ "Args", "returns", "the", "list", "of", "arguments", "for", "all", "parameters" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/schema/schema.go#L74-L80
142,101
gravitational/configure
schema/schema.go
Vars
func (p *ListParam) Vars() (string, string) { if len(p.values) == 0 { return p.Name(), p.Default() } out := make([]string, len(p.values)) for i, v := range p.values { _, out[i] = v.EnvVars() } return p.Name(), strings.Join(out, ",") }
go
func (p *ListParam) Vars() (string, string) { if len(p.values) == 0 { return p.Name(), p.Default() } out := make([]string, len(p.values)) for i, v := range p.values { _, out[i] = v.EnvVars() } return p.Name(), strings.Join(out, ",") }
[ "func", "(", "p", "*", "ListParam", ")", "Vars", "(", ")", "(", "string", ",", "string", ")", "{", "if", "len", "(", "p", ".", "values", ")", "==", "0", "{", "return", "p", ".", "Name", "(", ")", ",", "p", ".", "Default", "(", ")", "\n", "}...
// Vars returns a tuple with the variable name and value
[ "Vars", "returns", "a", "tuple", "with", "the", "variable", "name", "and", "value" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/schema/schema.go#L577-L586
142,102
gravitational/configure
cidr.go
CIDRFlag
func CIDRFlag(s kingpin.Settings) *CIDR { vars := new(CIDR) s.SetValue(vars) return vars }
go
func CIDRFlag(s kingpin.Settings) *CIDR { vars := new(CIDR) s.SetValue(vars) return vars }
[ "func", "CIDRFlag", "(", "s", "kingpin", ".", "Settings", ")", "*", "CIDR", "{", "vars", ":=", "new", "(", "CIDR", ")", "\n", "s", ".", "SetValue", "(", "vars", ")", "\n", "return", "vars", "\n", "}" ]
// CIDRFlag returns CIDR range flag
[ "CIDRFlag", "returns", "CIDR", "range", "flag" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cidr.go#L26-L30
142,103
gravitational/configure
cidr.go
ParseCIDR
func ParseCIDR(v string) (*CIDR, error) { ip, ipnet, err := net.ParseCIDR(v) if err != nil { return nil, trace.BadParameter("failed to parse CIDR(%v): %v", v, err.Error()) } return &CIDR{val: v, ip: ip, ipnet: *ipnet}, nil }
go
func ParseCIDR(v string) (*CIDR, error) { ip, ipnet, err := net.ParseCIDR(v) if err != nil { return nil, trace.BadParameter("failed to parse CIDR(%v): %v", v, err.Error()) } return &CIDR{val: v, ip: ip, ipnet: *ipnet}, nil }
[ "func", "ParseCIDR", "(", "v", "string", ")", "(", "*", "CIDR", ",", "error", ")", "{", "ip", ",", "ipnet", ",", "err", ":=", "net", ".", "ParseCIDR", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "BadP...
// ParseCIDR parses value of the CIDR from string
[ "ParseCIDR", "parses", "value", "of", "the", "CIDR", "from", "string" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cidr.go#L33-L39
142,104
gravitational/configure
cidr.go
FirstIP
func (c *CIDR) FirstIP() net.IP { var ip net.IP for ip = IncIP(c.ip.Mask(c.ipnet.Mask)); c.ipnet.Contains(ip); IncIP(ip) { break } return ip }
go
func (c *CIDR) FirstIP() net.IP { var ip net.IP for ip = IncIP(c.ip.Mask(c.ipnet.Mask)); c.ipnet.Contains(ip); IncIP(ip) { break } return ip }
[ "func", "(", "c", "*", "CIDR", ")", "FirstIP", "(", ")", "net", ".", "IP", "{", "var", "ip", "net", ".", "IP", "\n", "for", "ip", "=", "IncIP", "(", "c", ".", "ip", ".", "Mask", "(", "c", ".", "ipnet", ".", "Mask", ")", ")", ";", "c", "."...
// FirstIP returns the first IP in this subnet that is not .0
[ "FirstIP", "returns", "the", "first", "IP", "in", "this", "subnet", "that", "is", "not", ".", "0" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cidr.go#L62-L68
142,105
gravitational/configure
cli.go
ParseCommandLine
func ParseCommandLine(v interface{}, args []string) error { app, err := NewCommandLineApp(v) if err != nil { return trace.Wrap(err) } if _, err := app.Parse(args); err != nil { return trace.Wrap(err) } return nil }
go
func ParseCommandLine(v interface{}, args []string) error { app, err := NewCommandLineApp(v) if err != nil { return trace.Wrap(err) } if _, err := app.Parse(args); err != nil { return trace.Wrap(err) } return nil }
[ "func", "ParseCommandLine", "(", "v", "interface", "{", "}", ",", "args", "[", "]", "string", ")", "error", "{", "app", ",", "err", ":=", "NewCommandLineApp", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", ...
// ParseCommandLine takes a pointer to a function and attempts // to initialize it from environment variables.
[ "ParseCommandLine", "takes", "a", "pointer", "to", "a", "function", "and", "attempts", "to", "initialize", "it", "from", "environment", "variables", "." ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cli.go#L31-L40
142,106
gravitational/configure
cli.go
NewCommandLineApp
func NewCommandLineApp(v interface{}) (*kingpin.Application, error) { s := reflect.ValueOf(v).Elem() app := kingpin.New("app", "Auto generated command line application") if err := setupApp(app, s); err != nil { return nil, trace.Wrap(err) } return app, nil }
go
func NewCommandLineApp(v interface{}) (*kingpin.Application, error) { s := reflect.ValueOf(v).Elem() app := kingpin.New("app", "Auto generated command line application") if err := setupApp(app, s); err != nil { return nil, trace.Wrap(err) } return app, nil }
[ "func", "NewCommandLineApp", "(", "v", "interface", "{", "}", ")", "(", "*", "kingpin", ".", "Application", ",", "error", ")", "{", "s", ":=", "reflect", ".", "ValueOf", "(", "v", ")", ".", "Elem", "(", ")", "\n", "app", ":=", "kingpin", ".", "New"...
// NewCommandLineApp generates a command line parsing tool based on the struct // that was passed in as a parameter
[ "NewCommandLineApp", "generates", "a", "command", "line", "parsing", "tool", "based", "on", "the", "struct", "that", "was", "passed", "in", "as", "a", "parameter" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cli.go#L44-L51
142,107
gravitational/configure
kv.go
KeyValParam
func KeyValParam(s kingpin.Settings) *KeyVal { kv := make(KeyVal) s.SetValue(&kv) return &kv }
go
func KeyValParam(s kingpin.Settings) *KeyVal { kv := make(KeyVal) s.SetValue(&kv) return &kv }
[ "func", "KeyValParam", "(", "s", "kingpin", ".", "Settings", ")", "*", "KeyVal", "{", "kv", ":=", "make", "(", "KeyVal", ")", "\n", "s", ".", "SetValue", "(", "&", "kv", ")", "\n", "return", "&", "kv", "\n", "}" ]
// KeyValParam accepts a kingpin setting parameter and returns // kingpin-compatible value
[ "KeyValParam", "accepts", "a", "kingpin", "setting", "parameter", "and", "returns", "kingpin", "-", "compatible", "value" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/kv.go#L68-L72
142,108
gravitational/configure
kv.go
SetEnv
func (kv *KeyValSlice) SetEnv(v string) error { if err := json.Unmarshal([]byte(v), &kv); err != nil { return trace.Wrap( err, "failed to parse environment variable, expected JSON map") } return nil }
go
func (kv *KeyValSlice) SetEnv(v string) error { if err := json.Unmarshal([]byte(v), &kv); err != nil { return trace.Wrap( err, "failed to parse environment variable, expected JSON map") } return nil }
[ "func", "(", "kv", "*", "KeyValSlice", ")", "SetEnv", "(", "v", "string", ")", "error", "{", "if", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "v", ")", ",", "&", "kv", ")", ";", "err", "!=", "nil", "{", "return", "trace"...
// SetEnv sets the value from environment variable using json encoding
[ "SetEnv", "sets", "the", "value", "from", "environment", "variable", "using", "json", "encoding" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/kv.go#L91-L97
142,109
gravitational/configure
env.go
ParseEnv
func ParseEnv(v interface{}) error { env, err := parseEnvironment() if err != nil { return err } s := reflect.ValueOf(v).Elem() return setEnv(s, env) }
go
func ParseEnv(v interface{}) error { env, err := parseEnvironment() if err != nil { return err } s := reflect.ValueOf(v).Elem() return setEnv(s, env) }
[ "func", "ParseEnv", "(", "v", "interface", "{", "}", ")", "error", "{", "env", ",", "err", ":=", "parseEnvironment", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "s", ":=", "reflect", ".", "ValueOf", "(", "v", ...
// ParseEnv takes a pointer to a struct and attempts // to initialize it from environment variables.
[ "ParseEnv", "takes", "a", "pointer", "to", "a", "struct", "and", "attempts", "to", "initialize", "it", "from", "environment", "variables", "." ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/env.go#L30-L37
142,110
qor/l10n
scope.go
IsLocalizable
func IsLocalizable(scope *gorm.Scope) (IsLocalizable bool) { if scope.GetModelStruct().ModelType == nil { return false } _, IsLocalizable = reflect.New(scope.GetModelStruct().ModelType).Interface().(l10nInterface) return }
go
func IsLocalizable(scope *gorm.Scope) (IsLocalizable bool) { if scope.GetModelStruct().ModelType == nil { return false } _, IsLocalizable = reflect.New(scope.GetModelStruct().ModelType).Interface().(l10nInterface) return }
[ "func", "IsLocalizable", "(", "scope", "*", "gorm", ".", "Scope", ")", "(", "IsLocalizable", "bool", ")", "{", "if", "scope", ".", "GetModelStruct", "(", ")", ".", "ModelType", "==", "nil", "{", "return", "false", "\n", "}", "\n", "_", ",", "IsLocaliza...
// IsLocalizable return model is localizable or not
[ "IsLocalizable", "return", "model", "is", "localizable", "or", "not" ]
2ca95fb3b4dd41059a5329b615a6f5c96afe8ee7
https://github.com/qor/l10n/blob/2ca95fb3b4dd41059a5329b615a6f5c96afe8ee7/scope.go#L11-L17
142,111
qor/l10n
publish/publish.go
RegisterL10nForPublish
func RegisterL10nForPublish(Publish *publish.Publish, Admin *admin.Admin) { searchHandler := Publish.SearchHandler Publish.SearchHandler = func(db *gorm.DB, context *qor.Context) *gorm.DB { if context != nil { if context.Request != nil && context.Request.URL.Query().Get("locale") == "" { publishableLocales :...
go
func RegisterL10nForPublish(Publish *publish.Publish, Admin *admin.Admin) { searchHandler := Publish.SearchHandler Publish.SearchHandler = func(db *gorm.DB, context *qor.Context) *gorm.DB { if context != nil { if context.Request != nil && context.Request.URL.Query().Get("locale") == "" { publishableLocales :...
[ "func", "RegisterL10nForPublish", "(", "Publish", "*", "publish", ".", "Publish", ",", "Admin", "*", "admin", ".", "Admin", ")", "{", "searchHandler", ":=", "Publish", ".", "SearchHandler", "\n", "Publish", ".", "SearchHandler", "=", "func", "(", "db", "*", ...
// RegisterL10nForPublish register l10n language switcher for publish
[ "RegisterL10nForPublish", "register", "l10n", "language", "switcher", "for", "publish" ]
2ca95fb3b4dd41059a5329b615a6f5c96afe8ee7
https://github.com/qor/l10n/blob/2ca95fb3b4dd41059a5329b615a6f5c96afe8ee7/publish/publish.go#L42-L66
142,112
aodin/date
date.go
AddDate
func (date Date) AddDate(years, months, days int) Date { return Date{Time: date.Time.AddDate(years, months, days)} }
go
func (date Date) AddDate(years, months, days int) Date { return Date{Time: date.Time.AddDate(years, months, days)} }
[ "func", "(", "date", "Date", ")", "AddDate", "(", "years", ",", "months", ",", "days", "int", ")", "Date", "{", "return", "Date", "{", "Time", ":", "date", ".", "Time", ".", "AddDate", "(", "years", ",", "months", ",", "days", ")", "}", "\n", "}"...
// AddDate adds any number of years, months, and days to the date. // It proxies to the embedded time.Time, but returns a Date
[ "AddDate", "adds", "any", "number", "of", "years", "months", "and", "days", "to", "the", "date", ".", "It", "proxies", "to", "the", "embedded", "time", ".", "Time", "but", "returns", "a", "Date" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/date.go#L21-L23
142,113
aodin/date
date.go
Equals
func (date Date) Equals(other Date) bool { return date.Time.Equal(other.Time) }
go
func (date Date) Equals(other Date) bool { return date.Time.Equal(other.Time) }
[ "func", "(", "date", "Date", ")", "Equals", "(", "other", "Date", ")", "bool", "{", "return", "date", ".", "Time", ".", "Equal", "(", "other", ".", "Time", ")", "\n", "}" ]
// Equals returns true if the dates are equal
[ "Equals", "returns", "true", "if", "the", "dates", "are", "equal" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/date.go#L48-L50
142,114
aodin/date
date.go
UnmarshalJSON
func (date *Date) UnmarshalJSON(text []byte) error { if string(text) == "null" { // Nulls are converted to zero times var zero Date *date = zero return nil } b := bytes.NewBuffer(text) dec := json.NewDecoder(b) var s string if err := dec.Decode(&s); err != nil { return err } value, err := time.Parse(I...
go
func (date *Date) UnmarshalJSON(text []byte) error { if string(text) == "null" { // Nulls are converted to zero times var zero Date *date = zero return nil } b := bytes.NewBuffer(text) dec := json.NewDecoder(b) var s string if err := dec.Decode(&s); err != nil { return err } value, err := time.Parse(I...
[ "func", "(", "date", "*", "Date", ")", "UnmarshalJSON", "(", "text", "[", "]", "byte", ")", "error", "{", "if", "string", "(", "text", ")", "==", "\"", "\"", "{", "// Nulls are converted to zero times", "var", "zero", "Date", "\n", "*", "date", "=", "z...
// UnmarshalJSON converts a byte array into a Date
[ "UnmarshalJSON", "converts", "a", "byte", "array", "into", "a", "Date" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/date.go#L53-L72
142,115
aodin/date
date.go
MarshalJSON
func (date Date) MarshalJSON() ([]byte, error) { if date.IsZero() { return []byte("null"), nil } return []byte(`"` + date.format() + `"`), nil }
go
func (date Date) MarshalJSON() ([]byte, error) { if date.IsZero() { return []byte("null"), nil } return []byte(`"` + date.format() + `"`), nil }
[ "func", "(", "date", "Date", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "date", ".", "IsZero", "(", ")", "{", "return", "[", "]", "byte", "(", "\"", "\"", ")", ",", "nil", "\n", "}", "\n", "return", "["...
// MarshalJSON returns the JSON output of a Date. // Null will return a zero value date.
[ "MarshalJSON", "returns", "the", "JSON", "output", "of", "a", "Date", ".", "Null", "will", "return", "a", "zero", "value", "date", "." ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/date.go#L76-L81
142,116
aodin/date
date.go
Scan
func (date *Date) Scan(value interface{}) error { date.Time = value.(time.Time) return nil }
go
func (date *Date) Scan(value interface{}) error { date.Time = value.(time.Time) return nil }
[ "func", "(", "date", "*", "Date", ")", "Scan", "(", "value", "interface", "{", "}", ")", "error", "{", "date", ".", "Time", "=", "value", ".", "(", "time", ".", "Time", ")", "\n", "return", "nil", "\n", "}" ]
// Scan converts an SQL value into a Date
[ "Scan", "converts", "an", "SQL", "value", "into", "a", "Date" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/date.go#L84-L87
142,117
aodin/date
date.go
Within
func (date Date) Within(term Range) bool { // Empty terms contain nothing if term.IsEmpty() { return false } // Only check if the range is bounded if !term.Start.IsZero() && date.Before(term.Start) { return false } if !term.End.IsZero() && date.After(term.End) { return false } return true }
go
func (date Date) Within(term Range) bool { // Empty terms contain nothing if term.IsEmpty() { return false } // Only check if the range is bounded if !term.Start.IsZero() && date.Before(term.Start) { return false } if !term.End.IsZero() && date.After(term.End) { return false } return true }
[ "func", "(", "date", "Date", ")", "Within", "(", "term", "Range", ")", "bool", "{", "// Empty terms contain nothing", "if", "term", ".", "IsEmpty", "(", ")", "{", "return", "false", "\n", "}", "\n", "// Only check if the range is bounded", "if", "!", "term", ...
// Within returns true if the Date is within the Range - inclusive
[ "Within", "returns", "true", "if", "the", "Date", "is", "within", "the", "Range", "-", "inclusive" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/date.go#L95-L108
142,118
aodin/date
date.go
New
func New(year int, month time.Month, day int) Date { // Remove all second and nano second information and mark as UTC return Date{Time: time.Date(year, month, day, 0, 0, 0, 0, time.UTC)} }
go
func New(year int, month time.Month, day int) Date { // Remove all second and nano second information and mark as UTC return Date{Time: time.Date(year, month, day, 0, 0, 0, 0, time.UTC)} }
[ "func", "New", "(", "year", "int", ",", "month", "time", ".", "Month", ",", "day", "int", ")", "Date", "{", "// Remove all second and nano second information and mark as UTC", "return", "Date", "{", "Time", ":", "time", ".", "Date", "(", "year", ",", "month", ...
// New creates a new Date
[ "New", "creates", "a", "new", "Date" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/date.go#L121-L124
142,119
aodin/date
date.go
ParseUsingLayout
func ParseUsingLayout(format, value string) (Date, error) { t, err := time.Parse(format, value) if err != nil { return Date{}, err } return Date{Time: t}, nil }
go
func ParseUsingLayout(format, value string) (Date, error) { t, err := time.Parse(format, value) if err != nil { return Date{}, err } return Date{Time: t}, nil }
[ "func", "ParseUsingLayout", "(", "format", ",", "value", "string", ")", "(", "Date", ",", "error", ")", "{", "t", ",", "err", ":=", "time", ".", "Parse", "(", "format", ",", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Date", "{", ...
// ParseUsingLayout calls Parse with a different date layout
[ "ParseUsingLayout", "calls", "Parse", "with", "a", "different", "date", "layout" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/date.go#L132-L138
142,120
aodin/date
range.go
Contains
func (term Range) Contains(other Range) bool { return term.Intersection(other).Equals(other) }
go
func (term Range) Contains(other Range) bool { return term.Intersection(other).Equals(other) }
[ "func", "(", "term", "Range", ")", "Contains", "(", "other", "Range", ")", "bool", "{", "return", "term", ".", "Intersection", "(", "other", ")", ".", "Equals", "(", "other", ")", "\n", "}" ]
// Contains returns true if the given range is entirely within the // the range - inclusive
[ "Contains", "returns", "true", "if", "the", "given", "range", "is", "entirely", "within", "the", "the", "range", "-", "inclusive" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L20-L22
142,121
aodin/date
range.go
Error
func (term Range) Error() error { if term.Start.IsZero() || term.End.IsZero() { return nil } // One day only is allowed if term.Start.After(term.End) { return fmt.Errorf("Start date cannot be after the end date") } return nil }
go
func (term Range) Error() error { if term.Start.IsZero() || term.End.IsZero() { return nil } // One day only is allowed if term.Start.After(term.End) { return fmt.Errorf("Start date cannot be after the end date") } return nil }
[ "func", "(", "term", "Range", ")", "Error", "(", ")", "error", "{", "if", "term", ".", "Start", ".", "IsZero", "(", ")", "||", "term", ".", "End", ".", "IsZero", "(", ")", "{", "return", "nil", "\n", "}", "\n", "// One day only is allowed", "if", "...
// Error returns an error if there is both a start and end date and the given // start date is not before the end date.
[ "Error", "returns", "an", "error", "if", "there", "is", "both", "a", "start", "and", "end", "date", "and", "the", "given", "start", "date", "is", "not", "before", "the", "end", "date", "." ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L35-L44
142,122
aodin/date
range.go
IsZero
func (term Range) IsZero() bool { return term.Start.IsZero() && term.End.IsZero() }
go
func (term Range) IsZero() bool { return term.Start.IsZero() && term.End.IsZero() }
[ "func", "(", "term", "Range", ")", "IsZero", "(", ")", "bool", "{", "return", "term", ".", "Start", ".", "IsZero", "(", ")", "&&", "term", ".", "End", ".", "IsZero", "(", ")", "\n", "}" ]
// IsZero returns true if the start and end dates are both zero
[ "IsZero", "returns", "true", "if", "the", "start", "and", "end", "dates", "are", "both", "zero" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L57-L59
142,123
aodin/date
range.go
splitRange
func splitRange(value string) (string, string, error) { p := strings.SplitN(value, ",", 2) if len(p) != 2 || p[0] == "" || p[1] == "" { return "", "", fmt.Errorf("date: failed to parse date range '%s'", value) } return strings.ToLower(p[0][1:]), strings.ToLower(p[1][:len(p[1])-1]), nil }
go
func splitRange(value string) (string, string, error) { p := strings.SplitN(value, ",", 2) if len(p) != 2 || p[0] == "" || p[1] == "" { return "", "", fmt.Errorf("date: failed to parse date range '%s'", value) } return strings.ToLower(p[0][1:]), strings.ToLower(p[1][:len(p[1])-1]), nil }
[ "func", "splitRange", "(", "value", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "p", ":=", "strings", ".", "SplitN", "(", "value", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "p", ")", "!=", "2", "||", "p", ...
// splitRange divides a term into start and end date strings
[ "splitRange", "divides", "a", "term", "into", "start", "and", "end", "date", "strings" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L77-L83
142,124
aodin/date
range.go
Scan
func (term *Range) Scan(value interface{}) error { if value == nil { term.isEmpty = true // NULL should be an empty term return nil } b, ok := value.([]byte) if !ok { return fmt.Errorf("date: failed to convert date range to []byte") } // Zero ranges return "empty" if isEmptyRange(string(b)) { term.isEm...
go
func (term *Range) Scan(value interface{}) error { if value == nil { term.isEmpty = true // NULL should be an empty term return nil } b, ok := value.([]byte) if !ok { return fmt.Errorf("date: failed to convert date range to []byte") } // Zero ranges return "empty" if isEmptyRange(string(b)) { term.isEm...
[ "func", "(", "term", "*", "Range", ")", "Scan", "(", "value", "interface", "{", "}", ")", "error", "{", "if", "value", "==", "nil", "{", "term", ".", "isEmpty", "=", "true", "// NULL should be an empty term", "\n", "return", "nil", "\n", "}", "\n\n", "...
// Scan converts the given database value to a Range, // possibly returning an error if the conversion failed
[ "Scan", "converts", "the", "given", "database", "value", "to", "a", "Range", "possibly", "returning", "an", "error", "if", "the", "conversion", "failed" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L87-L133
142,125
aodin/date
range.go
String
func (term Range) String() string { if term.IsEmpty() { return "never" } if term.IsZero() { return "forever" } if term.Start.IsZero() { return fmt.Sprintf("until %s", term.End) } if term.End.IsZero() { return fmt.Sprintf("%s onward", term.Start) } return fmt.Sprintf("%s to %s", term.Start, term.End) }
go
func (term Range) String() string { if term.IsEmpty() { return "never" } if term.IsZero() { return "forever" } if term.Start.IsZero() { return fmt.Sprintf("until %s", term.End) } if term.End.IsZero() { return fmt.Sprintf("%s onward", term.Start) } return fmt.Sprintf("%s to %s", term.Start, term.End) }
[ "func", "(", "term", "Range", ")", "String", "(", ")", "string", "{", "if", "term", ".", "IsEmpty", "(", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "term", ".", "IsZero", "(", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "if", ...
// String returns a string representation of the date range
[ "String", "returns", "a", "string", "representation", "of", "the", "date", "range" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L136-L150
142,126
aodin/date
range.go
Overlaps
func (term Range) Overlaps(other Range) bool { return !term.Intersection(other).IsEmpty() }
go
func (term Range) Overlaps(other Range) bool { return !term.Intersection(other).IsEmpty() }
[ "func", "(", "term", "Range", ")", "Overlaps", "(", "other", "Range", ")", "bool", "{", "return", "!", "term", ".", "Intersection", "(", "other", ")", ".", "IsEmpty", "(", ")", "\n", "}" ]
// Overlaps returns true if the given range has at least one day // in common with the range
[ "Overlaps", "returns", "true", "if", "the", "given", "range", "has", "at", "least", "one", "day", "in", "common", "with", "the", "range" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L154-L156
142,127
aodin/date
range.go
Intersection
func (term Range) Intersection(other Range) (intersect Range) { // If either range is empty then the intersection is empty if term.IsEmpty() || other.IsEmpty() { intersect = Empty() return } if other.Start.Within(term) { intersect.Start = other.Start } else if term.Start.Within(other) { intersect.Start = ...
go
func (term Range) Intersection(other Range) (intersect Range) { // If either range is empty then the intersection is empty if term.IsEmpty() || other.IsEmpty() { intersect = Empty() return } if other.Start.Within(term) { intersect.Start = other.Start } else if term.Start.Within(other) { intersect.Start = ...
[ "func", "(", "term", "Range", ")", "Intersection", "(", "other", "Range", ")", "(", "intersect", "Range", ")", "{", "// If either range is empty then the intersection is empty", "if", "term", ".", "IsEmpty", "(", ")", "||", "other", ".", "IsEmpty", "(", ")", "...
// Intersection returns a new range consisting of the days the given // ranges have in common
[ "Intersection", "returns", "a", "new", "range", "consisting", "of", "the", "days", "the", "given", "ranges", "have", "in", "common" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L160-L189
142,128
aodin/date
range.go
MarshalJSON
func (term Range) MarshalJSON() ([]byte, error) { if term.IsEmpty() { return []byte("null"), nil } start, err := json.Marshal(term.Start) if err != nil { return nil, err } end, err := json.Marshal(term.End) if err != nil { return nil, err } return []byte(fmt.Sprintf(`{"start":%s,"end":%s}`, start, end)),...
go
func (term Range) MarshalJSON() ([]byte, error) { if term.IsEmpty() { return []byte("null"), nil } start, err := json.Marshal(term.Start) if err != nil { return nil, err } end, err := json.Marshal(term.End) if err != nil { return nil, err } return []byte(fmt.Sprintf(`{"start":%s,"end":%s}`, start, end)),...
[ "func", "(", "term", "Range", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "term", ".", "IsEmpty", "(", ")", "{", "return", "[", "]", "byte", "(", "\"", "\"", ")", ",", "nil", "\n", "}", "\n", "start", ",...
// MarshalJSON returns the JSON output of a Range. // Empty ranges will return null
[ "MarshalJSON", "returns", "the", "JSON", "output", "of", "a", "Range", ".", "Empty", "ranges", "will", "return", "null" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L193-L206
142,129
aodin/date
range.go
Union
func (term Range) Union(other Range) (union Range) { if term.IsEmpty() && other.IsEmpty() { union = Empty() return } if !term.IsEmpty() && term.Start.IsZero() { // Unbounded } else if !other.IsEmpty() && other.Start.IsZero() { // Unbounded } else if term.Start.Before(other.Start) { union.Start = term.Sta...
go
func (term Range) Union(other Range) (union Range) { if term.IsEmpty() && other.IsEmpty() { union = Empty() return } if !term.IsEmpty() && term.Start.IsZero() { // Unbounded } else if !other.IsEmpty() && other.Start.IsZero() { // Unbounded } else if term.Start.Before(other.Start) { union.Start = term.Sta...
[ "func", "(", "term", "Range", ")", "Union", "(", "other", "Range", ")", "(", "union", "Range", ")", "{", "if", "term", ".", "IsEmpty", "(", ")", "&&", "other", ".", "IsEmpty", "(", ")", "{", "union", "=", "Empty", "(", ")", "\n", "return", "\n", ...
// Union creates the union of two Range types. If there is a gap // between the two range it is included.
[ "Union", "creates", "the", "union", "of", "two", "Range", "types", ".", "If", "there", "is", "a", "gap", "between", "the", "two", "range", "it", "is", "included", "." ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L210-L234
142,130
aodin/date
range.go
Value
func (term Range) Value() (driver.Value, error) { if term.IsZero() { return "[,]", nil } if term.Start.IsZero() { return fmt.Sprintf("[,'%s']", term.End), nil } if term.End.IsZero() { return fmt.Sprintf("['%s',]", term.Start), nil } return fmt.Sprintf("['%s','%s']", term.Start, term.End), nil }
go
func (term Range) Value() (driver.Value, error) { if term.IsZero() { return "[,]", nil } if term.Start.IsZero() { return fmt.Sprintf("[,'%s']", term.End), nil } if term.End.IsZero() { return fmt.Sprintf("['%s',]", term.Start), nil } return fmt.Sprintf("['%s','%s']", term.Start, term.End), nil }
[ "func", "(", "term", "Range", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "if", "term", ".", "IsZero", "(", ")", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "if", "term", ".", "Start", ".", "IsZero",...
// Value prepares the nullable term for the database
[ "Value", "prepares", "the", "nullable", "term", "for", "the", "database" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L237-L248
142,131
aodin/date
range.go
NewRange
func NewRange(start, end Date) (term Range) { term.Start = start term.End = end return }
go
func NewRange(start, end Date) (term Range) { term.Start = start term.End = end return }
[ "func", "NewRange", "(", "start", ",", "end", "Date", ")", "(", "term", "Range", ")", "{", "term", ".", "Start", "=", "start", "\n", "term", ".", "End", "=", "end", "\n", "return", "\n", "}" ]
// NewRange creates a Range with the given start and end dates
[ "NewRange", "creates", "a", "Range", "with", "the", "given", "start", "and", "end", "dates" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L272-L276
142,132
aodin/date
range.go
EntireMonth
func EntireMonth(year int, month time.Month) (term Range) { first := time.Date(year, month, 1, 0, 0, 0, 0, time.UTC) term.End = FromTime(first.AddDate(0, 1, -1)) term.Start = FromTime(first) return }
go
func EntireMonth(year int, month time.Month) (term Range) { first := time.Date(year, month, 1, 0, 0, 0, 0, time.UTC) term.End = FromTime(first.AddDate(0, 1, -1)) term.Start = FromTime(first) return }
[ "func", "EntireMonth", "(", "year", "int", ",", "month", "time", ".", "Month", ")", "(", "term", "Range", ")", "{", "first", ":=", "time", ".", "Date", "(", "year", ",", "month", ",", "1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "time", ...
// EntireMonth creates a Range that includes the entire month
[ "EntireMonth", "creates", "a", "Range", "that", "includes", "the", "entire", "month" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L279-L284
142,133
aodin/date
range.go
EntireYear
func EntireYear(year int) (term Range) { first := time.Date(year, 1, 1, 0, 0, 0, 0, time.UTC) term.End = FromTime(first.AddDate(1, 0, -1)) term.Start = FromTime(first) return }
go
func EntireYear(year int) (term Range) { first := time.Date(year, 1, 1, 0, 0, 0, 0, time.UTC) term.End = FromTime(first.AddDate(1, 0, -1)) term.Start = FromTime(first) return }
[ "func", "EntireYear", "(", "year", "int", ")", "(", "term", "Range", ")", "{", "first", ":=", "time", ".", "Date", "(", "year", ",", "1", ",", "1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "time", ".", "UTC", ")", "\n", "term", ".", "En...
// EntireYear creates a Range that includes the entire year
[ "EntireYear", "creates", "a", "Range", "that", "includes", "the", "entire", "year" ]
c5f6146fc644cedc004c6d9e419094a60a6f653e
https://github.com/aodin/date/blob/c5f6146fc644cedc004c6d9e419094a60a6f653e/range.go#L287-L292
142,134
ramr/go-reaper
reaper.go
reapChildren
func reapChildren(config Config) { var notifications = make(chan os.Signal, 1) go sigChildHandler(notifications) pid := config.Pid opts := config.Options for { var sig = <-notifications fmt.Printf(" - Received signal %v\n", sig) for { var wstatus syscall.WaitStatus /* * Reap 'em, so that zombi...
go
func reapChildren(config Config) { var notifications = make(chan os.Signal, 1) go sigChildHandler(notifications) pid := config.Pid opts := config.Options for { var sig = <-notifications fmt.Printf(" - Received signal %v\n", sig) for { var wstatus syscall.WaitStatus /* * Reap 'em, so that zombi...
[ "func", "reapChildren", "(", "config", "Config", ")", "{", "var", "notifications", "=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n\n", "go", "sigChildHandler", "(", "notifications", ")", "\n\n", "pid", ":=", "config", ".", "Pid", "\n", ...
// Be a good parent - clean up behind the children.
[ "Be", "a", "good", "parent", "-", "clean", "up", "behind", "the", "children", "." ]
35f6a64e44ff062abfcec2d27cef674212d445c0
https://github.com/ramr/go-reaper/blob/35f6a64e44ff062abfcec2d27cef674212d445c0/reaper.go#L40-L73
142,135
ramr/go-reaper
reaper.go
Start
func Start(config Config) { /* * Start the Reaper with configuration options. This allows you to * reap processes even if the current pid isn't running as pid 1. * So ... use with caution!! * * In most cases, you are better off just using Reap() as that * checks if we are running as Pid 1. */ if !c...
go
func Start(config Config) { /* * Start the Reaper with configuration options. This allows you to * reap processes even if the current pid isn't running as pid 1. * So ... use with caution!! * * In most cases, you are better off just using Reap() as that * checks if we are running as Pid 1. */ if !c...
[ "func", "Start", "(", "config", "Config", ")", "{", "/*\n\t * Start the Reaper with configuration options. This allows you to\n\t * reap processes even if the current pid isn't running as pid 1.\n\t * So ... use with caution!!\n\t *\n\t * In most cases, you are better off just using Reap() as that...
// Entry point for invoking the reaper code with a specific configuration. // The config allows you to bypass the pid 1 checks, so handle with care. // The child processes are reaped in the background inside a goroutine.
[ "Entry", "point", "for", "invoking", "the", "reaper", "code", "with", "a", "specific", "configuration", ".", "The", "config", "allows", "you", "to", "bypass", "the", "pid", "1", "checks", "so", "handle", "with", "care", ".", "The", "child", "processes", "a...
35f6a64e44ff062abfcec2d27cef674212d445c0
https://github.com/ramr/go-reaper/blob/35f6a64e44ff062abfcec2d27cef674212d445c0/reaper.go#L100-L124
142,136
tebeka/snowball
snowball.go
free
func free(stmr *Stemmer) { if stmr.stmr != nil { C.sb_stemmer_delete(stmr.stmr) stmr.stmr = nil } }
go
func free(stmr *Stemmer) { if stmr.stmr != nil { C.sb_stemmer_delete(stmr.stmr) stmr.stmr = nil } }
[ "func", "free", "(", "stmr", "*", "Stemmer", ")", "{", "if", "stmr", ".", "stmr", "!=", "nil", "{", "C", ".", "sb_stemmer_delete", "(", "stmr", ".", "stmr", ")", "\n", "stmr", ".", "stmr", "=", "nil", "\n", "}", "\n", "}" ]
// free C resources
[ "free", "C", "resources" ]
d468c88a2299484454ff21b19d145024f5e82e3d
https://github.com/tebeka/snowball/blob/d468c88a2299484454ff21b19d145024f5e82e3d/snowball.go#L28-L33
142,137
tebeka/snowball
snowball.go
New
func New(lang string) (*Stemmer, error) { clang := C.CString(lang) defer C.free(unsafe.Pointer(clang)) stmr := &Stemmer{ lang, C.sb_stemmer_new(clang, nil), } if stmr.stmr == nil { return nil, fmt.Errorf("can't create stemmer for lang %s", lang) } runtime.SetFinalizer(stmr, free) return stmr, nil }
go
func New(lang string) (*Stemmer, error) { clang := C.CString(lang) defer C.free(unsafe.Pointer(clang)) stmr := &Stemmer{ lang, C.sb_stemmer_new(clang, nil), } if stmr.stmr == nil { return nil, fmt.Errorf("can't create stemmer for lang %s", lang) } runtime.SetFinalizer(stmr, free) return stmr, nil }
[ "func", "New", "(", "lang", "string", ")", "(", "*", "Stemmer", ",", "error", ")", "{", "clang", ":=", "C", ".", "CString", "(", "lang", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "clang", ")", ")", "\n\n", "stmr", ...
// New creates a new stemmer for lang
[ "New", "creates", "a", "new", "stemmer", "for", "lang" ]
d468c88a2299484454ff21b19d145024f5e82e3d
https://github.com/tebeka/snowball/blob/d468c88a2299484454ff21b19d145024f5e82e3d/snowball.go#L36-L52
142,138
lovoo/gcloud-opentracing
recorder.go
NewRecorder
func NewRecorder(ctx context.Context, projectID string, c TraceClient, opts ...Option) (*Recorder, error) { if projectID == "" { return nil, ErrInvalidProjectID } var options Options for _, o := range opts { o(&options) } if options.log == nil { options.log = &defaultLogger{} } rec := &Recorder{ proj...
go
func NewRecorder(ctx context.Context, projectID string, c TraceClient, opts ...Option) (*Recorder, error) { if projectID == "" { return nil, ErrInvalidProjectID } var options Options for _, o := range opts { o(&options) } if options.log == nil { options.log = &defaultLogger{} } rec := &Recorder{ proj...
[ "func", "NewRecorder", "(", "ctx", "context", ".", "Context", ",", "projectID", "string", ",", "c", "TraceClient", ",", "opts", "...", "Option", ")", "(", "*", "Recorder", ",", "error", ")", "{", "if", "projectID", "==", "\"", "\"", "{", "return", "nil...
// NewRecorder creates new GCloud StackDriver recorder.
[ "NewRecorder", "creates", "new", "GCloud", "StackDriver", "recorder", "." ]
9a3ba70d6a016bafc680df855bd7ed25b81fad5f
https://github.com/lovoo/gcloud-opentracing/blob/9a3ba70d6a016bafc680df855bd7ed25b81fad5f/recorder.go#L45-L81
142,139
lovoo/gcloud-opentracing
recorder.go
RecordSpan
func (r *Recorder) RecordSpan(sp basictracer.RawSpan) { if !sp.Context.Sampled { return } traceID := fmt.Sprintf("%016x%016x", sp.Context.TraceID, sp.Context.TraceID) nanos := sp.Start.UnixNano() labels := convertTags(sp.Tags) transposeLabels(labels) addLogs(labels, sp.Logs) trace := &pb.Trace{ ProjectId:...
go
func (r *Recorder) RecordSpan(sp basictracer.RawSpan) { if !sp.Context.Sampled { return } traceID := fmt.Sprintf("%016x%016x", sp.Context.TraceID, sp.Context.TraceID) nanos := sp.Start.UnixNano() labels := convertTags(sp.Tags) transposeLabels(labels) addLogs(labels, sp.Logs) trace := &pb.Trace{ ProjectId:...
[ "func", "(", "r", "*", "Recorder", ")", "RecordSpan", "(", "sp", "basictracer", ".", "RawSpan", ")", "{", "if", "!", "sp", ".", "Context", ".", "Sampled", "{", "return", "\n", "}", "\n\n", "traceID", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",...
// RecordSpan writes Span to the GCLoud StackDriver.
[ "RecordSpan", "writes", "Span", "to", "the", "GCLoud", "StackDriver", "." ]
9a3ba70d6a016bafc680df855bd7ed25b81fad5f
https://github.com/lovoo/gcloud-opentracing/blob/9a3ba70d6a016bafc680df855bd7ed25b81fad5f/recorder.go#L84-L126
142,140
lovoo/gcloud-opentracing
recorder.go
Close
func (r *Recorder) Close() error { r.bundler.Flush() return r.traceClient.Close() }
go
func (r *Recorder) Close() error { r.bundler.Flush() return r.traceClient.Close() }
[ "func", "(", "r", "*", "Recorder", ")", "Close", "(", ")", "error", "{", "r", ".", "bundler", ".", "Flush", "(", ")", "\n", "return", "r", ".", "traceClient", ".", "Close", "(", ")", "\n", "}" ]
// Close flushes all the recorder traces and closes the client.
[ "Close", "flushes", "all", "the", "recorder", "traces", "and", "closes", "the", "client", "." ]
9a3ba70d6a016bafc680df855bd7ed25b81fad5f
https://github.com/lovoo/gcloud-opentracing/blob/9a3ba70d6a016bafc680df855bd7ed25b81fad5f/recorder.go#L129-L132
142,141
lovoo/gcloud-opentracing
recorder.go
transposeLabels
func transposeLabels(labels map[string]string) { for k, t := range labelMap { if vv, ok := labels[k]; ok { labels[t] = vv delete(labels, k) } } }
go
func transposeLabels(labels map[string]string) { for k, t := range labelMap { if vv, ok := labels[k]; ok { labels[t] = vv delete(labels, k) } } }
[ "func", "transposeLabels", "(", "labels", "map", "[", "string", "]", "string", ")", "{", "for", "k", ",", "t", ":=", "range", "labelMap", "{", "if", "vv", ",", "ok", ":=", "labels", "[", "k", "]", ";", "ok", "{", "labels", "[", "t", "]", "=", "...
// rewrite well-known opentracing.ext labels into those gcloud-native labels
[ "rewrite", "well", "-", "known", "opentracing", ".", "ext", "labels", "into", "those", "gcloud", "-", "native", "labels" ]
9a3ba70d6a016bafc680df855bd7ed25b81fad5f
https://github.com/lovoo/gcloud-opentracing/blob/9a3ba70d6a016bafc680df855bd7ed25b81fad5f/recorder.go#L174-L181
142,142
lovoo/gcloud-opentracing
recorder.go
addLogs
func addLogs(target map[string]string, logs []opentracing.LogRecord) { for i, l := range logs { buf := bytes.NewBufferString(l.Timestamp.String()) for j, f := range l.Fields { buf.WriteString(f.Key()) buf.WriteString("=") buf.WriteString(fmt.Sprint(f.Value())) if j != len(l.Fields)+1 { buf.WriteStr...
go
func addLogs(target map[string]string, logs []opentracing.LogRecord) { for i, l := range logs { buf := bytes.NewBufferString(l.Timestamp.String()) for j, f := range l.Fields { buf.WriteString(f.Key()) buf.WriteString("=") buf.WriteString(fmt.Sprint(f.Value())) if j != len(l.Fields)+1 { buf.WriteStr...
[ "func", "addLogs", "(", "target", "map", "[", "string", "]", "string", ",", "logs", "[", "]", "opentracing", ".", "LogRecord", ")", "{", "for", "i", ",", "l", ":=", "range", "logs", "{", "buf", ":=", "bytes", ".", "NewBufferString", "(", "l", ".", ...
// copy opentracing events into gcloud trace labels
[ "copy", "opentracing", "events", "into", "gcloud", "trace", "labels" ]
9a3ba70d6a016bafc680df855bd7ed25b81fad5f
https://github.com/lovoo/gcloud-opentracing/blob/9a3ba70d6a016bafc680df855bd7ed25b81fad5f/recorder.go#L184-L197
142,143
herenow/go-crate
crate.go
Open
func (c *CrateDriver) Open(crate_url string) (driver.Conn, error) { u, err := url.Parse(crate_url) if err != nil { return nil, err } sanUrl := fmt.Sprintf("%s://%s", u.Scheme, u.Host) c.Url = sanUrl c.httpClient = &http.Client{} if u.User != nil { username := u.User.Username() password, _ := u.User.Pas...
go
func (c *CrateDriver) Open(crate_url string) (driver.Conn, error) { u, err := url.Parse(crate_url) if err != nil { return nil, err } sanUrl := fmt.Sprintf("%s://%s", u.Scheme, u.Host) c.Url = sanUrl c.httpClient = &http.Client{} if u.User != nil { username := u.User.Username() password, _ := u.User.Pas...
[ "func", "(", "c", "*", "CrateDriver", ")", "Open", "(", "crate_url", "string", ")", "(", "driver", ".", "Conn", ",", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "crate_url", ")", "\n\n", "if", "err", "!=", "nil", "{", "ret...
// Init a new "Connection" to a Crate Data Storage instance. // Note that the connection is not tested until the first query.
[ "Init", "a", "new", "Connection", "to", "a", "Crate", "Data", "Storage", "instance", ".", "Note", "that", "the", "connection", "is", "not", "tested", "until", "the", "first", "query", "." ]
55fcd153f4b64659f05ad2399666d4666dbd2ad5
https://github.com/herenow/go-crate/blob/55fcd153f4b64659f05ad2399666d4666dbd2ad5/crate.go#L26-L47
142,144
herenow/go-crate
crate.go
Query
func (c *CrateDriver) Query(stmt string, args []driver.Value) (driver.Rows, error) { res, err := c.query(stmt, args) if err != nil { return nil, err } // Rows reader rows := &Rows{ columns: res.Cols, values: res.Rows, rowcount: res.Rowcount, } return rows, nil }
go
func (c *CrateDriver) Query(stmt string, args []driver.Value) (driver.Rows, error) { res, err := c.query(stmt, args) if err != nil { return nil, err } // Rows reader rows := &Rows{ columns: res.Cols, values: res.Rows, rowcount: res.Rowcount, } return rows, nil }
[ "func", "(", "c", "*", "CrateDriver", ")", "Query", "(", "stmt", "string", ",", "args", "[", "]", "driver", ".", "Value", ")", "(", "driver", ".", "Rows", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "query", "(", "stmt", ",", "ar...
// Queries the database
[ "Queries", "the", "database" ]
55fcd153f4b64659f05ad2399666d4666dbd2ad5
https://github.com/herenow/go-crate/blob/55fcd153f4b64659f05ad2399666d4666dbd2ad5/crate.go#L148-L163
142,145
herenow/go-crate
crate.go
Exec
func (c *CrateDriver) Exec(stmt string, args []driver.Value) (result driver.Result, err error) { res, err := c.query(stmt, args) if err != nil { return nil, err } result = &Result{res.Rowcount} return result, nil }
go
func (c *CrateDriver) Exec(stmt string, args []driver.Value) (result driver.Result, err error) { res, err := c.query(stmt, args) if err != nil { return nil, err } result = &Result{res.Rowcount} return result, nil }
[ "func", "(", "c", "*", "CrateDriver", ")", "Exec", "(", "stmt", "string", ",", "args", "[", "]", "driver", ".", "Value", ")", "(", "result", "driver", ".", "Result", ",", "err", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "query", "(", ...
// Exec queries on the dataabase
[ "Exec", "queries", "on", "the", "dataabase" ]
55fcd153f4b64659f05ad2399666d4666dbd2ad5
https://github.com/herenow/go-crate/blob/55fcd153f4b64659f05ad2399666d4666dbd2ad5/crate.go#L166-L176
142,146
herenow/go-crate
crate.go
Next
func (r *Rows) Next(dest []driver.Value) error { if r.pos >= r.rowcount { return io.EOF } for i := range dest { dest[i] = r.values[r.pos][i] } r.pos++ return nil }
go
func (r *Rows) Next(dest []driver.Value) error { if r.pos >= r.rowcount { return io.EOF } for i := range dest { dest[i] = r.values[r.pos][i] } r.pos++ return nil }
[ "func", "(", "r", "*", "Rows", ")", "Next", "(", "dest", "[", "]", "driver", ".", "Value", ")", "error", "{", "if", "r", ".", "pos", ">=", "r", ".", "rowcount", "{", "return", "io", ".", "EOF", "\n", "}", "\n\n", "for", "i", ":=", "range", "d...
// Get the next row
[ "Get", "the", "next", "row" ]
55fcd153f4b64659f05ad2399666d4666dbd2ad5
https://github.com/herenow/go-crate/blob/55fcd153f4b64659f05ad2399666d4666dbd2ad5/crate.go#L208-L220
142,147
herenow/go-crate
crate.go
Begin
func (c *CrateDriver) Begin() (driver.Tx, error) { err := errors.New("Transactions are not supported by this driver.") return nil, err }
go
func (c *CrateDriver) Begin() (driver.Tx, error) { err := errors.New("Transactions are not supported by this driver.") return nil, err }
[ "func", "(", "c", "*", "CrateDriver", ")", "Begin", "(", ")", "(", "driver", ".", "Tx", ",", "error", ")", "{", "err", ":=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "return", "nil", ",", "err", "\n", "}" ]
// Yet not supported
[ "Yet", "not", "supported" ]
55fcd153f4b64659f05ad2399666d4666dbd2ad5
https://github.com/herenow/go-crate/blob/55fcd153f4b64659f05ad2399666d4666dbd2ad5/crate.go#L229-L232
142,148
herenow/go-crate
crate.go
Prepare
func (c *CrateDriver) Prepare(query string) (driver.Stmt, error) { stmt := &CrateStmt{ stmt: query, driver: c, } return stmt, nil }
go
func (c *CrateDriver) Prepare(query string) (driver.Stmt, error) { stmt := &CrateStmt{ stmt: query, driver: c, } return stmt, nil }
[ "func", "(", "c", "*", "CrateDriver", ")", "Prepare", "(", "query", "string", ")", "(", "driver", ".", "Stmt", ",", "error", ")", "{", "stmt", ":=", "&", "CrateStmt", "{", "stmt", ":", "query", ",", "driver", ":", "c", ",", "}", "\n\n", "return", ...
// Driver method that initiates the prepared stmt interface
[ "Driver", "method", "that", "initiates", "the", "prepared", "stmt", "interface" ]
55fcd153f4b64659f05ad2399666d4666dbd2ad5
https://github.com/herenow/go-crate/blob/55fcd153f4b64659f05ad2399666d4666dbd2ad5/crate.go#L246-L253
142,149
sbstjn/allot
match.go
String
func (m Match) String(name string) (string, error) { return m.Parameter(NewParameterWithType(name, "string")) }
go
func (m Match) String(name string) (string, error) { return m.Parameter(NewParameterWithType(name, "string")) }
[ "func", "(", "m", "Match", ")", "String", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "return", "m", ".", "Parameter", "(", "NewParameterWithType", "(", "name", ",", "\"", "\"", ")", ")", "\n", "}" ]
// String returns the value for a string parameter
[ "String", "returns", "the", "value", "for", "a", "string", "parameter" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/match.go#L25-L27
142,150
sbstjn/allot
match.go
Integer
func (m Match) Integer(name string) (int, error) { str, err := m.Parameter(NewParameterWithType(name, "integer")) if err != nil { return 0, err } return strconv.Atoi(str) }
go
func (m Match) Integer(name string) (int, error) { str, err := m.Parameter(NewParameterWithType(name, "integer")) if err != nil { return 0, err } return strconv.Atoi(str) }
[ "func", "(", "m", "Match", ")", "Integer", "(", "name", "string", ")", "(", "int", ",", "error", ")", "{", "str", ",", "err", ":=", "m", ".", "Parameter", "(", "NewParameterWithType", "(", "name", ",", "\"", "\"", ")", ")", "\n", "if", "err", "!=...
// Integer returns the value for an integer parameter
[ "Integer", "returns", "the", "value", "for", "an", "integer", "parameter" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/match.go#L30-L37
142,151
sbstjn/allot
match.go
Parameter
func (m Match) Parameter(param ParameterInterface) (string, error) { pos := m.Command.Position(param) if pos == -1 { return "", errors.New("Unknonw parameter \"" + param.Name() + "\"") } matches := m.Command.Expression().FindAllStringSubmatch(m.Request, -1)[0][1:] return matches[m.Command.Position(param)], nil ...
go
func (m Match) Parameter(param ParameterInterface) (string, error) { pos := m.Command.Position(param) if pos == -1 { return "", errors.New("Unknonw parameter \"" + param.Name() + "\"") } matches := m.Command.Expression().FindAllStringSubmatch(m.Request, -1)[0][1:] return matches[m.Command.Position(param)], nil ...
[ "func", "(", "m", "Match", ")", "Parameter", "(", "param", "ParameterInterface", ")", "(", "string", ",", "error", ")", "{", "pos", ":=", "m", ".", "Command", ".", "Position", "(", "param", ")", "\n", "if", "pos", "==", "-", "1", "{", "return", "\"...
// Parameter returns the value for a parameter
[ "Parameter", "returns", "the", "value", "for", "a", "parameter" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/match.go#L40-L48
142,152
sbstjn/allot
match.go
Match
func (m Match) Match(position int) (string, error) { matches := m.Command.Expression().FindAllStringSubmatch(m.Request, -1) if len(matches) != 1 { return "", errors.New("Unable to parse request") } if position >= len(matches[0]) { return "", fmt.Errorf("No parameter at position %d", position) } return matc...
go
func (m Match) Match(position int) (string, error) { matches := m.Command.Expression().FindAllStringSubmatch(m.Request, -1) if len(matches) != 1 { return "", errors.New("Unable to parse request") } if position >= len(matches[0]) { return "", fmt.Errorf("No parameter at position %d", position) } return matc...
[ "func", "(", "m", "Match", ")", "Match", "(", "position", "int", ")", "(", "string", ",", "error", ")", "{", "matches", ":=", "m", ".", "Command", ".", "Expression", "(", ")", ".", "FindAllStringSubmatch", "(", "m", ".", "Request", ",", "-", "1", "...
// Match returns the match at given position
[ "Match", "returns", "the", "match", "at", "given", "position" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/match.go#L51-L63
142,153
sbstjn/allot
command.go
Expression
func (c Command) Expression() *regexp.Regexp { expr := c.Text() for _, param := range c.Parameters() { expr = strings.Replace(expr, "<"+param.Name()+":"+param.Data()+">", "("+param.Expression().String()+")", -1) expr = strings.Replace(expr, "<"+param.Name()+">", "("+param.Expression().String()+")", -1) } retu...
go
func (c Command) Expression() *regexp.Regexp { expr := c.Text() for _, param := range c.Parameters() { expr = strings.Replace(expr, "<"+param.Name()+":"+param.Data()+">", "("+param.Expression().String()+")", -1) expr = strings.Replace(expr, "<"+param.Name()+">", "("+param.Expression().String()+")", -1) } retu...
[ "func", "(", "c", "Command", ")", "Expression", "(", ")", "*", "regexp", ".", "Regexp", "{", "expr", ":=", "c", ".", "Text", "(", ")", "\n\n", "for", "_", ",", "param", ":=", "range", "c", ".", "Parameters", "(", ")", "{", "expr", "=", "strings",...
// Expression returns the regular expression matching the command text
[ "Expression", "returns", "the", "regular", "expression", "matching", "the", "command", "text" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/command.go#L31-L40
142,154
sbstjn/allot
command.go
Parameters
func (c Command) Parameters() []Parameter { var list []Parameter re := regexp.MustCompile("<(.*?)>") result := re.FindAllStringSubmatch(c.Text(), -1) for _, p := range result { if len(p) != 2 { continue } pType := "" if !strings.Contains(p[1], ":") { pType = ":string" } list = append(list, Pars...
go
func (c Command) Parameters() []Parameter { var list []Parameter re := regexp.MustCompile("<(.*?)>") result := re.FindAllStringSubmatch(c.Text(), -1) for _, p := range result { if len(p) != 2 { continue } pType := "" if !strings.Contains(p[1], ":") { pType = ":string" } list = append(list, Pars...
[ "func", "(", "c", "Command", ")", "Parameters", "(", ")", "[", "]", "Parameter", "{", "var", "list", "[", "]", "Parameter", "\n", "re", ":=", "regexp", ".", "MustCompile", "(", "\"", "\"", ")", "\n", "result", ":=", "re", ".", "FindAllStringSubmatch", ...
// Parameters returns the list of defined parameters
[ "Parameters", "returns", "the", "list", "of", "defined", "parameters" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/command.go#L43-L62
142,155
sbstjn/allot
command.go
Position
func (c Command) Position(param ParameterInterface) int { for index, item := range c.Parameters() { if item.Equals(param) { return index } } return -1 }
go
func (c Command) Position(param ParameterInterface) int { for index, item := range c.Parameters() { if item.Equals(param) { return index } } return -1 }
[ "func", "(", "c", "Command", ")", "Position", "(", "param", "ParameterInterface", ")", "int", "{", "for", "index", ",", "item", ":=", "range", "c", ".", "Parameters", "(", ")", "{", "if", "item", ".", "Equals", "(", "param", ")", "{", "return", "inde...
// Position returns the position of a parameter
[ "Position", "returns", "the", "position", "of", "a", "parameter" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/command.go#L70-L78
142,156
sbstjn/allot
command.go
Match
func (c Command) Match(req string) (MatchInterface, error) { if c.Matches(req) { return Match{c, req}, nil } return nil, errors.New("Request does not match Command.") }
go
func (c Command) Match(req string) (MatchInterface, error) { if c.Matches(req) { return Match{c, req}, nil } return nil, errors.New("Request does not match Command.") }
[ "func", "(", "c", "Command", ")", "Match", "(", "req", "string", ")", "(", "MatchInterface", ",", "error", ")", "{", "if", "c", ".", "Matches", "(", "req", ")", "{", "return", "Match", "{", "c", ",", "req", "}", ",", "nil", "\n", "}", "\n\n", "...
// Match returns the parameter matching the expression at the defined position
[ "Match", "returns", "the", "parameter", "matching", "the", "expression", "at", "the", "defined", "position" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/command.go#L81-L87
142,157
sbstjn/allot
command.go
Matches
func (c Command) Matches(req string) bool { return c.Expression().MatchString(req) }
go
func (c Command) Matches(req string) bool { return c.Expression().MatchString(req) }
[ "func", "(", "c", "Command", ")", "Matches", "(", "req", "string", ")", "bool", "{", "return", "c", ".", "Expression", "(", ")", ".", "MatchString", "(", "req", ")", "\n", "}" ]
// Matches checks if a comand definition matches a request
[ "Matches", "checks", "if", "a", "comand", "definition", "matches", "a", "request" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/command.go#L90-L92
142,158
sbstjn/allot
parameter.go
Expression
func Expression(data string) *regexp.Regexp { if exp, ok := regexpMapping[data]; ok { return regexp.MustCompile(exp) } return nil }
go
func Expression(data string) *regexp.Regexp { if exp, ok := regexpMapping[data]; ok { return regexp.MustCompile(exp) } return nil }
[ "func", "Expression", "(", "data", "string", ")", "*", "regexp", ".", "Regexp", "{", "if", "exp", ",", "ok", ":=", "regexpMapping", "[", "data", "]", ";", "ok", "{", "return", "regexp", ".", "MustCompile", "(", "exp", ")", "\n", "}", "\n\n", "return"...
// Expression returns the regexp for a data type
[ "Expression", "returns", "the", "regexp", "for", "a", "data", "type" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/parameter.go#L14-L20
142,159
sbstjn/allot
parameter.go
Equals
func (p Parameter) Equals(param ParameterInterface) bool { return p.Name() == param.Name() && p.Expression().String() == param.Expression().String() }
go
func (p Parameter) Equals(param ParameterInterface) bool { return p.Name() == param.Name() && p.Expression().String() == param.Expression().String() }
[ "func", "(", "p", "Parameter", ")", "Equals", "(", "param", "ParameterInterface", ")", "bool", "{", "return", "p", ".", "Name", "(", ")", "==", "param", ".", "Name", "(", ")", "&&", "p", ".", "Expression", "(", ")", ".", "String", "(", ")", "==", ...
// Equals checks if two parameter are equal
[ "Equals", "checks", "if", "two", "parameter", "are", "equal" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/parameter.go#L53-L55
142,160
sbstjn/allot
parameter.go
Parse
func Parse(text string) Parameter { var splits []string var name, data string name = strings.Replace(text, "<", "", -1) name = strings.Replace(name, ">", "", -1) data = "string" if strings.Contains(name, ":") { splits = strings.Split(name, ":") name = splits[0] data = splits[1] } return NewParameterWi...
go
func Parse(text string) Parameter { var splits []string var name, data string name = strings.Replace(text, "<", "", -1) name = strings.Replace(name, ">", "", -1) data = "string" if strings.Contains(name, ":") { splits = strings.Split(name, ":") name = splits[0] data = splits[1] } return NewParameterWi...
[ "func", "Parse", "(", "text", "string", ")", "Parameter", "{", "var", "splits", "[", "]", "string", "\n", "var", "name", ",", "data", "string", "\n\n", "name", "=", "strings", ".", "Replace", "(", "text", ",", "\"", "\"", ",", "\"", "\"", ",", "-",...
// Parse parses parameter info
[ "Parse", "parses", "parameter", "info" ]
1f2349af5ccd74c1a8d8fe4d1bf688645b628321
https://github.com/sbstjn/allot/blob/1f2349af5ccd74c1a8d8fe4d1bf688645b628321/parameter.go#L63-L79
142,161
tomnomnom/linkheader
main.go
HasParam
func (l Link) HasParam(key string) bool { for p := range l.Params { if p == key { return true } } return false }
go
func (l Link) HasParam(key string) bool { for p := range l.Params { if p == key { return true } } return false }
[ "func", "(", "l", "Link", ")", "HasParam", "(", "key", "string", ")", "bool", "{", "for", "p", ":=", "range", "l", ".", "Params", "{", "if", "p", "==", "key", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// HasParam returns if a Link has a particular parameter or not
[ "HasParam", "returns", "if", "a", "Link", "has", "a", "particular", "parameter", "or", "not" ]
02ca5825eb8097f10d9cc53da78481a85ad84e04
https://github.com/tomnomnom/linkheader/blob/02ca5825eb8097f10d9cc53da78481a85ad84e04/main.go#L17-L24
142,162
tomnomnom/linkheader
main.go
Param
func (l Link) Param(key string) string { for k, v := range l.Params { if key == k { return v } } return "" }
go
func (l Link) Param(key string) string { for k, v := range l.Params { if key == k { return v } } return "" }
[ "func", "(", "l", "Link", ")", "Param", "(", "key", "string", ")", "string", "{", "for", "k", ",", "v", ":=", "range", "l", ".", "Params", "{", "if", "key", "==", "k", "{", "return", "v", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", "\n"...
// Param returns the value of a parameter if it exists
[ "Param", "returns", "the", "value", "of", "a", "parameter", "if", "it", "exists" ]
02ca5825eb8097f10d9cc53da78481a85ad84e04
https://github.com/tomnomnom/linkheader/blob/02ca5825eb8097f10d9cc53da78481a85ad84e04/main.go#L27-L34
142,163
tomnomnom/linkheader
main.go
String
func (l Link) String() string { p := make([]string, 0, len(l.Params)) for k, v := range l.Params { p = append(p, fmt.Sprintf("%s=\"%s\"", k, v)) } if l.Rel != "" { p = append(p, fmt.Sprintf("%s=\"%s\"", "rel", l.Rel)) } return fmt.Sprintf("<%s>; %s", l.URL, strings.Join(p, "; ")) }
go
func (l Link) String() string { p := make([]string, 0, len(l.Params)) for k, v := range l.Params { p = append(p, fmt.Sprintf("%s=\"%s\"", k, v)) } if l.Rel != "" { p = append(p, fmt.Sprintf("%s=\"%s\"", "rel", l.Rel)) } return fmt.Sprintf("<%s>; %s", l.URL, strings.Join(p, "; ")) }
[ "func", "(", "l", "Link", ")", "String", "(", ")", "string", "{", "p", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "l", ".", "Params", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "l", ".", "Params", "{", "p", ...
// String returns the string representation of a link
[ "String", "returns", "the", "string", "representation", "of", "a", "link" ]
02ca5825eb8097f10d9cc53da78481a85ad84e04
https://github.com/tomnomnom/linkheader/blob/02ca5825eb8097f10d9cc53da78481a85ad84e04/main.go#L37-L47
142,164
tomnomnom/linkheader
main.go
FilterByRel
func (l Links) FilterByRel(r string) Links { links := make(Links, 0) for _, link := range l { if link.Rel == r { links = append(links, link) } } return links }
go
func (l Links) FilterByRel(r string) Links { links := make(Links, 0) for _, link := range l { if link.Rel == r { links = append(links, link) } } return links }
[ "func", "(", "l", "Links", ")", "FilterByRel", "(", "r", "string", ")", "Links", "{", "links", ":=", "make", "(", "Links", ",", "0", ")", "\n", "for", "_", ",", "link", ":=", "range", "l", "{", "if", "link", ".", "Rel", "==", "r", "{", "links",...
// FilterByRel filters a group of Links by the provided Rel attribute
[ "FilterByRel", "filters", "a", "group", "of", "Links", "by", "the", "provided", "Rel", "attribute" ]
02ca5825eb8097f10d9cc53da78481a85ad84e04
https://github.com/tomnomnom/linkheader/blob/02ca5825eb8097f10d9cc53da78481a85ad84e04/main.go#L53-L61
142,165
tomnomnom/linkheader
main.go
String
func (l Links) String() string { if l == nil { return fmt.Sprint(nil) } var strs []string for _, link := range l { strs = append(strs, link.String()) } return strings.Join(strs, ", ") }
go
func (l Links) String() string { if l == nil { return fmt.Sprint(nil) } var strs []string for _, link := range l { strs = append(strs, link.String()) } return strings.Join(strs, ", ") }
[ "func", "(", "l", "Links", ")", "String", "(", ")", "string", "{", "if", "l", "==", "nil", "{", "return", "fmt", ".", "Sprint", "(", "nil", ")", "\n", "}", "\n\n", "var", "strs", "[", "]", "string", "\n", "for", "_", ",", "link", ":=", "range",...
// String returns the string representation of multiple Links // for use in HTTP responses etc
[ "String", "returns", "the", "string", "representation", "of", "multiple", "Links", "for", "use", "in", "HTTP", "responses", "etc" ]
02ca5825eb8097f10d9cc53da78481a85ad84e04
https://github.com/tomnomnom/linkheader/blob/02ca5825eb8097f10d9cc53da78481a85ad84e04/main.go#L65-L75
142,166
tomnomnom/linkheader
main.go
ParseMultiple
func ParseMultiple(headers []string) Links { links := make(Links, 0) for _, header := range headers { links = append(links, Parse(header)...) } return links }
go
func ParseMultiple(headers []string) Links { links := make(Links, 0) for _, header := range headers { links = append(links, Parse(header)...) } return links }
[ "func", "ParseMultiple", "(", "headers", "[", "]", "string", ")", "Links", "{", "links", ":=", "make", "(", "Links", ",", "0", ")", "\n", "for", "_", ",", "header", ":=", "range", "headers", "{", "links", "=", "append", "(", "links", ",", "Parse", ...
// ParseMultiple is like Parse, but accepts a slice of headers // rather than just one header string
[ "ParseMultiple", "is", "like", "Parse", "but", "accepts", "a", "slice", "of", "headers", "rather", "than", "just", "one", "header", "string" ]
02ca5825eb8097f10d9cc53da78481a85ad84e04
https://github.com/tomnomnom/linkheader/blob/02ca5825eb8097f10d9cc53da78481a85ad84e04/main.go#L126-L132
142,167
tomnomnom/linkheader
main.go
parseParam
func parseParam(raw string) (key, val string) { parts := strings.SplitN(raw, "=", 2) if len(parts) == 1 { return parts[0], "" } if len(parts) != 2 { return "", "" } key = parts[0] val = strings.Trim(parts[1], "\"") return key, val }
go
func parseParam(raw string) (key, val string) { parts := strings.SplitN(raw, "=", 2) if len(parts) == 1 { return parts[0], "" } if len(parts) != 2 { return "", "" } key = parts[0] val = strings.Trim(parts[1], "\"") return key, val }
[ "func", "parseParam", "(", "raw", "string", ")", "(", "key", ",", "val", "string", ")", "{", "parts", ":=", "strings", ".", "SplitN", "(", "raw", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "parts", ")", "==", "1", "{", "return", "p...
// parseParam takes a raw param in the form key="val" and // returns the key and value as seperate strings
[ "parseParam", "takes", "a", "raw", "param", "in", "the", "form", "key", "=", "val", "and", "returns", "the", "key", "and", "value", "as", "seperate", "strings" ]
02ca5825eb8097f10d9cc53da78481a85ad84e04
https://github.com/tomnomnom/linkheader/blob/02ca5825eb8097f10d9cc53da78481a85ad84e04/main.go#L136-L151
142,168
philhofer/fwd
reader.go
Reset
func (r *Reader) Reset(rd io.Reader) { r.r = rd r.data = r.data[0:0] r.n = 0 r.state = nil if s, ok := rd.(io.Seeker); ok { r.rs = s } else { r.rs = nil } }
go
func (r *Reader) Reset(rd io.Reader) { r.r = rd r.data = r.data[0:0] r.n = 0 r.state = nil if s, ok := rd.(io.Seeker); ok { r.rs = s } else { r.rs = nil } }
[ "func", "(", "r", "*", "Reader", ")", "Reset", "(", "rd", "io", ".", "Reader", ")", "{", "r", ".", "r", "=", "rd", "\n", "r", ".", "data", "=", "r", ".", "data", "[", "0", ":", "0", "]", "\n", "r", ".", "n", "=", "0", "\n", "r", ".", ...
// Reset resets the underlying reader // and the read buffer.
[ "Reset", "resets", "the", "underlying", "reader", "and", "the", "read", "buffer", "." ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/reader.go#L81-L91
142,169
philhofer/fwd
reader.go
noEOF
func (r *Reader) noEOF() (e error) { e, r.state = r.state, nil if e == io.EOF { e = io.ErrUnexpectedEOF } return }
go
func (r *Reader) noEOF() (e error) { e, r.state = r.state, nil if e == io.EOF { e = io.ErrUnexpectedEOF } return }
[ "func", "(", "r", "*", "Reader", ")", "noEOF", "(", ")", "(", "e", "error", ")", "{", "e", ",", "r", ".", "state", "=", "r", ".", "state", ",", "nil", "\n", "if", "e", "==", "io", ".", "EOF", "{", "e", "=", "io", ".", "ErrUnexpectedEOF", "\...
// pop error; EOF -> io.ErrUnexpectedEOF
[ "pop", "error", ";", "EOF", "-", ">", "io", ".", "ErrUnexpectedEOF" ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/reader.go#L127-L133
142,170
philhofer/fwd
reader.go
Next
func (r *Reader) Next(n int) ([]byte, error) { // in case the buffer is too small if cap(r.data) < n { old := r.data[r.n:] r.data = make([]byte, n+r.buffered()) r.data = r.data[:copy(r.data, old)] r.n = 0 } // fill at least 'n' bytes for r.buffered() < n && r.state == nil { r.more() } if r.buffered(...
go
func (r *Reader) Next(n int) ([]byte, error) { // in case the buffer is too small if cap(r.data) < n { old := r.data[r.n:] r.data = make([]byte, n+r.buffered()) r.data = r.data[:copy(r.data, old)] r.n = 0 } // fill at least 'n' bytes for r.buffered() < n && r.state == nil { r.more() } if r.buffered(...
[ "func", "(", "r", "*", "Reader", ")", "Next", "(", "n", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// in case the buffer is too small", "if", "cap", "(", "r", ".", "data", ")", "<", "n", "{", "old", ":=", "r", ".", "data", "[", ...
// Next returns the next 'n' bytes in the stream. // Unlike Peek, Next advances the reader position. // The returned bytes point to the same // data as the buffer, so the slice is // only valid until the next reader method call. // An EOF is considered an unexpected error. // If an the returned slice is less than the /...
[ "Next", "returns", "the", "next", "n", "bytes", "in", "the", "stream", ".", "Unlike", "Peek", "Next", "advances", "the", "reader", "position", ".", "The", "returned", "bytes", "point", "to", "the", "same", "data", "as", "the", "buffer", "so", "the", "sli...
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/reader.go#L229-L250
142,171
philhofer/fwd
reader.go
ReadByte
func (r *Reader) ReadByte() (byte, error) { for r.buffered() < 1 && r.state == nil { r.more() } if r.buffered() < 1 { return 0, r.err() } b := r.data[r.n] r.n++ return b, nil }
go
func (r *Reader) ReadByte() (byte, error) { for r.buffered() < 1 && r.state == nil { r.more() } if r.buffered() < 1 { return 0, r.err() } b := r.data[r.n] r.n++ return b, nil }
[ "func", "(", "r", "*", "Reader", ")", "ReadByte", "(", ")", "(", "byte", ",", "error", ")", "{", "for", "r", ".", "buffered", "(", ")", "<", "1", "&&", "r", ".", "state", "==", "nil", "{", "r", ".", "more", "(", ")", "\n", "}", "\n", "if", ...
// ReadByte implements `io.ByteReader`
[ "ReadByte", "implements", "io", ".", "ByteReader" ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/reader.go#L322-L332
142,172
philhofer/fwd
writer.go
NewWriter
func NewWriter(w io.Writer) *Writer { if wr, ok := w.(*Writer); ok { return wr } return &Writer{ w: w, buf: make([]byte, 0, DefaultWriterSize), } }
go
func NewWriter(w io.Writer) *Writer { if wr, ok := w.(*Writer); ok { return wr } return &Writer{ w: w, buf: make([]byte, 0, DefaultWriterSize), } }
[ "func", "NewWriter", "(", "w", "io", ".", "Writer", ")", "*", "Writer", "{", "if", "wr", ",", "ok", ":=", "w", ".", "(", "*", "Writer", ")", ";", "ok", "{", "return", "wr", "\n", "}", "\n", "return", "&", "Writer", "{", "w", ":", "w", ",", ...
// NewWriter returns a new writer // that writes to 'w' and has a buffer // that is `DefaultWriterSize` bytes.
[ "NewWriter", "returns", "a", "new", "writer", "that", "writes", "to", "w", "and", "has", "a", "buffer", "that", "is", "DefaultWriterSize", "bytes", "." ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/writer.go#L22-L30
142,173
philhofer/fwd
writer.go
NewWriterSize
func NewWriterSize(w io.Writer, size int) *Writer { if wr, ok := w.(*Writer); ok && cap(wr.buf) >= size { return wr } return &Writer{ w: w, buf: make([]byte, 0, max(size, minWriterSize)), } }
go
func NewWriterSize(w io.Writer, size int) *Writer { if wr, ok := w.(*Writer); ok && cap(wr.buf) >= size { return wr } return &Writer{ w: w, buf: make([]byte, 0, max(size, minWriterSize)), } }
[ "func", "NewWriterSize", "(", "w", "io", ".", "Writer", ",", "size", "int", ")", "*", "Writer", "{", "if", "wr", ",", "ok", ":=", "w", ".", "(", "*", "Writer", ")", ";", "ok", "&&", "cap", "(", "wr", ".", "buf", ")", ">=", "size", "{", "retur...
// NewWriterSize returns a new writer // that writes to 'w' and has a buffer // that is 'size' bytes.
[ "NewWriterSize", "returns", "a", "new", "writer", "that", "writes", "to", "w", "and", "has", "a", "buffer", "that", "is", "size", "bytes", "." ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/writer.go#L35-L43
142,174
philhofer/fwd
writer.go
Flush
func (w *Writer) Flush() error { l := len(w.buf) if l > 0 { n, err := w.w.Write(w.buf) // if we didn't write the whole // thing, copy the unwritten // bytes to the beginnning of the // buffer. if n < l && n > 0 { w.pushback(n) if err == nil { err = io.ErrShortWrite } } if err != nil { ...
go
func (w *Writer) Flush() error { l := len(w.buf) if l > 0 { n, err := w.w.Write(w.buf) // if we didn't write the whole // thing, copy the unwritten // bytes to the beginnning of the // buffer. if n < l && n > 0 { w.pushback(n) if err == nil { err = io.ErrShortWrite } } if err != nil { ...
[ "func", "(", "w", "*", "Writer", ")", "Flush", "(", ")", "error", "{", "l", ":=", "len", "(", "w", ".", "buf", ")", "\n", "if", "l", ">", "0", "{", "n", ",", "err", ":=", "w", ".", "w", ".", "Write", "(", "w", ".", "buf", ")", "\n\n", "...
// Flush flushes any buffered bytes // to the underlying writer.
[ "Flush", "flushes", "any", "buffered", "bytes", "to", "the", "underlying", "writer", "." ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/writer.go#L54-L76
142,175
philhofer/fwd
writer.go
WriteString
func (w *Writer) WriteString(s string) (int, error) { c, l, ln := cap(w.buf), len(w.buf), len(s) avail := c - l // requires flush if avail < ln { if err := w.Flush(); err != nil { return 0, err } l = len(w.buf) } // too big to fit in buffer; // write directly to w.w // // yes, this is unsafe. *but* ...
go
func (w *Writer) WriteString(s string) (int, error) { c, l, ln := cap(w.buf), len(w.buf), len(s) avail := c - l // requires flush if avail < ln { if err := w.Flush(); err != nil { return 0, err } l = len(w.buf) } // too big to fit in buffer; // write directly to w.w // // yes, this is unsafe. *but* ...
[ "func", "(", "w", "*", "Writer", ")", "WriteString", "(", "s", "string", ")", "(", "int", ",", "error", ")", "{", "c", ",", "l", ",", "ln", ":=", "cap", "(", "w", ".", "buf", ")", ",", "len", "(", "w", ".", "buf", ")", ",", "len", "(", "s...
// WriteString is analogous to Write, but it takes a string.
[ "WriteString", "is", "analogous", "to", "Write", "but", "it", "takes", "a", "string", "." ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/writer.go#L102-L134
142,176
philhofer/fwd
writer.go
WriteByte
func (w *Writer) WriteByte(b byte) error { if len(w.buf) == cap(w.buf) { if err := w.Flush(); err != nil { return err } } w.buf = append(w.buf, b) return nil }
go
func (w *Writer) WriteByte(b byte) error { if len(w.buf) == cap(w.buf) { if err := w.Flush(); err != nil { return err } } w.buf = append(w.buf, b) return nil }
[ "func", "(", "w", "*", "Writer", ")", "WriteByte", "(", "b", "byte", ")", "error", "{", "if", "len", "(", "w", ".", "buf", ")", "==", "cap", "(", "w", ".", "buf", ")", "{", "if", "err", ":=", "w", ".", "Flush", "(", ")", ";", "err", "!=", ...
// WriteByte implements `io.ByteWriter`
[ "WriteByte", "implements", "io", ".", "ByteWriter" ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/writer.go#L137-L145
142,177
philhofer/fwd
writer.go
Next
func (w *Writer) Next(n int) ([]byte, error) { c, l := cap(w.buf), len(w.buf) if n > c { return nil, io.ErrShortBuffer } avail := c - l if avail < n { if err := w.Flush(); err != nil { return nil, err } l = len(w.buf) } w.buf = w.buf[:l+n] return w.buf[l:], nil }
go
func (w *Writer) Next(n int) ([]byte, error) { c, l := cap(w.buf), len(w.buf) if n > c { return nil, io.ErrShortBuffer } avail := c - l if avail < n { if err := w.Flush(); err != nil { return nil, err } l = len(w.buf) } w.buf = w.buf[:l+n] return w.buf[l:], nil }
[ "func", "(", "w", "*", "Writer", ")", "Next", "(", "n", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "c", ",", "l", ":=", "cap", "(", "w", ".", "buf", ")", ",", "len", "(", "w", ".", "buf", ")", "\n", "if", "n", ">", "c", ...
// Next returns the next 'n' free bytes // in the write buffer, flushing the writer // as necessary. Next will return `io.ErrShortBuffer` // if 'n' is greater than the size of the write buffer. // Calls to 'next' increment the write position by // the size of the returned buffer.
[ "Next", "returns", "the", "next", "n", "free", "bytes", "in", "the", "write", "buffer", "flushing", "the", "writer", "as", "necessary", ".", "Next", "will", "return", "io", ".", "ErrShortBuffer", "if", "n", "is", "greater", "than", "the", "size", "of", "...
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/writer.go#L153-L167
142,178
philhofer/fwd
writer.go
ReadFrom
func (w *Writer) ReadFrom(r io.Reader) (int64, error) { // anticipatory flush if err := w.Flush(); err != nil { return 0, err } w.buf = w.buf[0:cap(w.buf)] // expand buffer var nn int64 // written var err error // error var x int // read // 1:1 reads and writes for err == nil { x, err = r.Read(w.bu...
go
func (w *Writer) ReadFrom(r io.Reader) (int64, error) { // anticipatory flush if err := w.Flush(); err != nil { return 0, err } w.buf = w.buf[0:cap(w.buf)] // expand buffer var nn int64 // written var err error // error var x int // read // 1:1 reads and writes for err == nil { x, err = r.Read(w.bu...
[ "func", "(", "w", "*", "Writer", ")", "ReadFrom", "(", "r", "io", ".", "Reader", ")", "(", "int64", ",", "error", ")", "{", "// anticipatory flush", "if", "err", ":=", "w", ".", "Flush", "(", ")", ";", "err", "!=", "nil", "{", "return", "0", ",",...
// ReadFrom implements `io.ReaderFrom`
[ "ReadFrom", "implements", "io", ".", "ReaderFrom" ]
bb6d471dc95d4fe11e432687f8b70ff496cf3136
https://github.com/philhofer/fwd/blob/bb6d471dc95d4fe11e432687f8b70ff496cf3136/writer.go#L177-L224
142,179
tidwall/rtree
base/knn.go
KNN
func (tr *RTree) KNN(min, max []float64, center bool, iter func(item interface{}, dist float64) bool) bool { var isBox bool knnPoint := make([]float64, tr.dims) bbox := &treeNode{min: min, max: max} for i := 0; i < tr.dims; i++ { knnPoint[i] = (bbox.min[i] + bbox.max[i]) / 2 if !isBox && bbox.min[i] != bbox.m...
go
func (tr *RTree) KNN(min, max []float64, center bool, iter func(item interface{}, dist float64) bool) bool { var isBox bool knnPoint := make([]float64, tr.dims) bbox := &treeNode{min: min, max: max} for i := 0; i < tr.dims; i++ { knnPoint[i] = (bbox.min[i] + bbox.max[i]) / 2 if !isBox && bbox.min[i] != bbox.m...
[ "func", "(", "tr", "*", "RTree", ")", "KNN", "(", "min", ",", "max", "[", "]", "float64", ",", "center", "bool", ",", "iter", "func", "(", "item", "interface", "{", "}", ",", "dist", "float64", ")", "bool", ")", "bool", "{", "var", "isBox", "bool...
// KNN returns items nearest to farthest. The dist param is the "box distance".
[ "KNN", "returns", "items", "nearest", "to", "farthest", ".", "The", "dist", "param", "is", "the", "box", "distance", "." ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/knn.go#L18-L57
142,180
tidwall/rtree
base/rtree.go
New
func New(dims, maxEntries int) *RTree { if dims <= 0 { panic("invalid dimensions") } tr := &RTree{} tr.dims = dims tr.maxEntries = int(math.Max(4, float64(maxEntries))) tr.minEntries = int(math.Max(2, math.Ceil(float64(tr.maxEntries)*0.4))) tr.data = tr.createNode(nil) return tr }
go
func New(dims, maxEntries int) *RTree { if dims <= 0 { panic("invalid dimensions") } tr := &RTree{} tr.dims = dims tr.maxEntries = int(math.Max(4, float64(maxEntries))) tr.minEntries = int(math.Max(2, math.Ceil(float64(tr.maxEntries)*0.4))) tr.data = tr.createNode(nil) return tr }
[ "func", "New", "(", "dims", ",", "maxEntries", "int", ")", "*", "RTree", "{", "if", "dims", "<=", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "tr", ":=", "&", "RTree", "{", "}", "\n", "tr", ".", "dims", "=", "dims", "\n", "tr"...
// New creates a new R-tree
[ "New", "creates", "a", "new", "R", "-", "tree" ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/rtree.go#L205-L216
142,181
tidwall/rtree
base/rtree.go
Insert
func (tr *RTree) Insert(min, max []float64, item interface{}) { if len(min) != tr.dims || len(max) != tr.dims { panic("invalid dimensions") } if item == nil { panic("nil item") } bbox := treeNode{min: min, max: max} tr.insert(&bbox, item, tr.data.height-1, false) }
go
func (tr *RTree) Insert(min, max []float64, item interface{}) { if len(min) != tr.dims || len(max) != tr.dims { panic("invalid dimensions") } if item == nil { panic("nil item") } bbox := treeNode{min: min, max: max} tr.insert(&bbox, item, tr.data.height-1, false) }
[ "func", "(", "tr", "*", "RTree", ")", "Insert", "(", "min", ",", "max", "[", "]", "float64", ",", "item", "interface", "{", "}", ")", "{", "if", "len", "(", "min", ")", "!=", "tr", ".", "dims", "||", "len", "(", "max", ")", "!=", "tr", ".", ...
// Insert inserts an item
[ "Insert", "inserts", "an", "item" ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/rtree.go#L219-L228
142,182
tidwall/rtree
base/rtree.go
Search
func (tr *RTree) Search(min, max []float64, iter func(item interface{}) bool) bool { bbox := &treeNode{min: min, max: max} if !tr.data.intersects(bbox) { return true } return tr.search(tr.data, bbox, iter) }
go
func (tr *RTree) Search(min, max []float64, iter func(item interface{}) bool) bool { bbox := &treeNode{min: min, max: max} if !tr.data.intersects(bbox) { return true } return tr.search(tr.data, bbox, iter) }
[ "func", "(", "tr", "*", "RTree", ")", "Search", "(", "min", ",", "max", "[", "]", "float64", ",", "iter", "func", "(", "item", "interface", "{", "}", ")", "bool", ")", "bool", "{", "bbox", ":=", "&", "treeNode", "{", "min", ":", "min", ",", "ma...
// Search searches the tree for items in the input rectangle
[ "Search", "searches", "the", "tree", "for", "items", "in", "the", "input", "rectangle" ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/rtree.go#L459-L465
142,183
tidwall/rtree
base/rtree.go
Remove
func (tr *RTree) Remove(min, max []float64, item interface{}) { bbox := &treeNode{min: min, max: max} tr.remove(bbox, item) }
go
func (tr *RTree) Remove(min, max []float64, item interface{}) { bbox := &treeNode{min: min, max: max} tr.remove(bbox, item) }
[ "func", "(", "tr", "*", "RTree", ")", "Remove", "(", "min", ",", "max", "[", "]", "float64", ",", "item", "interface", "{", "}", ")", "{", "bbox", ":=", "&", "treeNode", "{", "min", ":", "min", ",", "max", ":", "max", "}", "\n", "tr", ".", "r...
// Remove removes an item from the R-tree.
[ "Remove", "removes", "an", "item", "from", "the", "R", "-", "tree", "." ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/rtree.go#L503-L506
142,184
tidwall/rtree
base/rtree.go
Traverse
func (tr *RTree) Traverse(iter func(min, max []float64, level int, item interface{}) bool) bool { return tr.traverse(tr.data, iter) }
go
func (tr *RTree) Traverse(iter func(min, max []float64, level int, item interface{}) bool) bool { return tr.traverse(tr.data, iter) }
[ "func", "(", "tr", "*", "RTree", ")", "Traverse", "(", "iter", "func", "(", "min", ",", "max", "[", "]", "float64", ",", "level", "int", ",", "item", "interface", "{", "}", ")", "bool", ")", "bool", "{", "return", "tr", ".", "traverse", "(", "tr"...
// Traverse iterates over the entire R-tree and includes all nodes and items.
[ "Traverse", "iterates", "over", "the", "entire", "R", "-", "tree", "and", "includes", "all", "nodes", "and", "items", "." ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/rtree.go#L601-L603
142,185
tidwall/rtree
base/rtree.go
Scan
func (tr *RTree) Scan(iter func(item interface{}) bool) bool { return scan(tr.data, iter) }
go
func (tr *RTree) Scan(iter func(item interface{}) bool) bool { return scan(tr.data, iter) }
[ "func", "(", "tr", "*", "RTree", ")", "Scan", "(", "iter", "func", "(", "item", "interface", "{", "}", ")", "bool", ")", "bool", "{", "return", "scan", "(", "tr", ".", "data", ",", "iter", ")", "\n", "}" ]
// Scan iterates over the entire R-tree
[ "Scan", "iterates", "over", "the", "entire", "R", "-", "tree" ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/rtree.go#L628-L630
142,186
tidwall/rtree
base/rtree.go
Bounds
func (tr *RTree) Bounds() (min, max []float64) { if tr.data.count > 0 { return tr.data.min, tr.data.max } return make([]float64, tr.dims), make([]float64, tr.dims) }
go
func (tr *RTree) Bounds() (min, max []float64) { if tr.data.count > 0 { return tr.data.min, tr.data.max } return make([]float64, tr.dims), make([]float64, tr.dims) }
[ "func", "(", "tr", "*", "RTree", ")", "Bounds", "(", ")", "(", "min", ",", "max", "[", "]", "float64", ")", "{", "if", "tr", ".", "data", ".", "count", ">", "0", "{", "return", "tr", ".", "data", ".", "min", ",", "tr", ".", "data", ".", "ma...
// Bounds returns the bounding box of the entire R-tree
[ "Bounds", "returns", "the", "bounding", "box", "of", "the", "entire", "R", "-", "tree" ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/rtree.go#L652-L657
142,187
tidwall/rtree
base/rtree.go
Complexity
func (tr *RTree) Complexity() float64 { var nodeCount int var itemCount int tr.Traverse(func(_, _ []float64, level int, _ interface{}) bool { if level == 0 { itemCount++ } else { nodeCount++ } return true }) return float64(tr.maxEntries*nodeCount) / float64(itemCount) }
go
func (tr *RTree) Complexity() float64 { var nodeCount int var itemCount int tr.Traverse(func(_, _ []float64, level int, _ interface{}) bool { if level == 0 { itemCount++ } else { nodeCount++ } return true }) return float64(tr.maxEntries*nodeCount) / float64(itemCount) }
[ "func", "(", "tr", "*", "RTree", ")", "Complexity", "(", ")", "float64", "{", "var", "nodeCount", "int", "\n", "var", "itemCount", "int", "\n", "tr", ".", "Traverse", "(", "func", "(", "_", ",", "_", "[", "]", "float64", ",", "level", "int", ",", ...
// Complexity returns the complexity of the R-tree. The higher the value, the // more complex the tree. The value of 1 is the lowest.
[ "Complexity", "returns", "the", "complexity", "of", "the", "R", "-", "tree", ".", "The", "higher", "the", "value", "the", "more", "complex", "the", "tree", ".", "The", "value", "of", "1", "is", "the", "lowest", "." ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/rtree.go#L661-L673
142,188
tidwall/rtree
base/load.go
Load
func (tr *RTree) Load(mins, maxs [][]float64, items []interface{}) { if len(items) < tr.minEntries { for i := 0; i < len(items); i++ { tr.Insert(mins[i], maxs[i], items[i]) } return } // prefill the items fitems := make([]*treeNode, len(items)) for i := 0; i < len(items); i++ { item := &treeItem{min: m...
go
func (tr *RTree) Load(mins, maxs [][]float64, items []interface{}) { if len(items) < tr.minEntries { for i := 0; i < len(items); i++ { tr.Insert(mins[i], maxs[i], items[i]) } return } // prefill the items fitems := make([]*treeNode, len(items)) for i := 0; i < len(items); i++ { item := &treeItem{min: m...
[ "func", "(", "tr", "*", "RTree", ")", "Load", "(", "mins", ",", "maxs", "[", "]", "[", "]", "float64", ",", "items", "[", "]", "interface", "{", "}", ")", "{", "if", "len", "(", "items", ")", "<", "tr", ".", "minEntries", "{", "for", "i", ":=...
// Load bulk load items into the R-tree.
[ "Load", "bulk", "load", "items", "into", "the", "R", "-", "tree", "." ]
6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3
https://github.com/tidwall/rtree/blob/6cd427091e0e662cb4f8e2c9eb1a41e1c46ff0d3/base/load.go#L6-L65
142,189
matryer/resync
once.go
Reset
func (o *Once) Reset() { o.m.Lock() defer o.m.Unlock() atomic.StoreUint32(&o.done, 0) }
go
func (o *Once) Reset() { o.m.Lock() defer o.m.Unlock() atomic.StoreUint32(&o.done, 0) }
[ "func", "(", "o", "*", "Once", ")", "Reset", "(", ")", "{", "o", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "m", ".", "Unlock", "(", ")", "\n", "atomic", ".", "StoreUint32", "(", "&", "o", ".", "done", ",", "0", ")", "\n", ...
// Reset indicates that the next call to Do should actually be called // once again.
[ "Reset", "indicates", "that", "the", "next", "call", "to", "Do", "should", "actually", "be", "called", "once", "again", "." ]
d39c09a11215c84aab0b65e323fc47dd6e276af1
https://github.com/matryer/resync/blob/d39c09a11215c84aab0b65e323fc47dd6e276af1/once.go#L34-L38
142,190
99designs/httpsignatures-go
signature.go
FromRequest
func FromRequest(r *http.Request) (*Signature, error) { if s, ok := r.Header[headerSignature]; ok { return FromString(s[0]) } if a, ok := r.Header[headerAuthorization]; ok { return FromString(strings.TrimPrefix(a[0], authScheme)) } return nil, ErrorNoSignatureHeader }
go
func FromRequest(r *http.Request) (*Signature, error) { if s, ok := r.Header[headerSignature]; ok { return FromString(s[0]) } if a, ok := r.Header[headerAuthorization]; ok { return FromString(strings.TrimPrefix(a[0], authScheme)) } return nil, ErrorNoSignatureHeader }
[ "func", "FromRequest", "(", "r", "*", "http", ".", "Request", ")", "(", "*", "Signature", ",", "error", ")", "{", "if", "s", ",", "ok", ":=", "r", ".", "Header", "[", "headerSignature", "]", ";", "ok", "{", "return", "FromString", "(", "s", "[", ...
// FromRequest creates a new Signature from the Request // both Signature and Authorization http headers are supported.
[ "FromRequest", "creates", "a", "new", "Signature", "from", "the", "Request", "both", "Signature", "and", "Authorization", "http", "headers", "are", "supported", "." ]
88528bf4ca7e0268c559d30cfa8825208313b3c0
https://github.com/99designs/httpsignatures-go/blob/88528bf4ca7e0268c559d30cfa8825208313b3c0/signature.go#L41-L49
142,191
99designs/httpsignatures-go
signature.go
FromString
func FromString(in string) (*Signature, error) { var res Signature = Signature{} var key string var value string for _, m := range signatureRegex.FindAllStringSubmatch(in, -1) { key = m[1] value = m[2] if key == "keyId" { res.KeyID = value } else if key == "algorithm" { alg, err := algorithmFromStri...
go
func FromString(in string) (*Signature, error) { var res Signature = Signature{} var key string var value string for _, m := range signatureRegex.FindAllStringSubmatch(in, -1) { key = m[1] value = m[2] if key == "keyId" { res.KeyID = value } else if key == "algorithm" { alg, err := algorithmFromStri...
[ "func", "FromString", "(", "in", "string", ")", "(", "*", "Signature", ",", "error", ")", "{", "var", "res", "Signature", "=", "Signature", "{", "}", "\n", "var", "key", "string", "\n", "var", "value", "string", "\n\n", "for", "_", ",", "m", ":=", ...
// FromString creates a new Signature from its encoded form, // eg `keyId="a",algorithm="b",headers="c",signature="d"`
[ "FromString", "creates", "a", "new", "Signature", "from", "its", "encoded", "form", "eg", "keyId", "=", "a", "algorithm", "=", "b", "headers", "=", "c", "signature", "=", "d" ]
88528bf4ca7e0268c559d30cfa8825208313b3c0
https://github.com/99designs/httpsignatures-go/blob/88528bf4ca7e0268c559d30cfa8825208313b3c0/signature.go#L53-L92
142,192
99designs/httpsignatures-go
signature.go
String
func (s Signature) String() string { str := fmt.Sprintf( `keyId="%s",algorithm="%s",signature="%s"`, s.KeyID, s.Algorithm.name, s.Signature, ) if len(s.Headers) > 0 { str += fmt.Sprintf(`,headers="%s"`, s.Headers.String()) } return str }
go
func (s Signature) String() string { str := fmt.Sprintf( `keyId="%s",algorithm="%s",signature="%s"`, s.KeyID, s.Algorithm.name, s.Signature, ) if len(s.Headers) > 0 { str += fmt.Sprintf(`,headers="%s"`, s.Headers.String()) } return str }
[ "func", "(", "s", "Signature", ")", "String", "(", ")", "string", "{", "str", ":=", "fmt", ".", "Sprintf", "(", "`keyId=\"%s\",algorithm=\"%s\",signature=\"%s\"`", ",", "s", ".", "KeyID", ",", "s", ".", "Algorithm", ".", "name", ",", "s", ".", "Signature",...
// String returns the encoded form of the Signature
[ "String", "returns", "the", "encoded", "form", "of", "the", "Signature" ]
88528bf4ca7e0268c559d30cfa8825208313b3c0
https://github.com/99designs/httpsignatures-go/blob/88528bf4ca7e0268c559d30cfa8825208313b3c0/signature.go#L95-L108
142,193
99designs/httpsignatures-go
signature.go
sign
func (s *Signature) sign(key string, r *http.Request) error { sig, err := s.calculateSignature(key, r) if err != nil { return err } s.Signature = sig return nil }
go
func (s *Signature) sign(key string, r *http.Request) error { sig, err := s.calculateSignature(key, r) if err != nil { return err } s.Signature = sig return nil }
[ "func", "(", "s", "*", "Signature", ")", "sign", "(", "key", "string", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "sig", ",", "err", ":=", "s", ".", "calculateSignature", "(", "key", ",", "r", ")", "\n", "if", "err", "!=", "nil", ...
// Sign this signature using the given key
[ "Sign", "this", "signature", "using", "the", "given", "key" ]
88528bf4ca7e0268c559d30cfa8825208313b3c0
https://github.com/99designs/httpsignatures-go/blob/88528bf4ca7e0268c559d30cfa8825208313b3c0/signature.go#L124-L132
142,194
99designs/httpsignatures-go
signature.go
IsValid
func (s Signature) IsValid(key string, r *http.Request) bool { if !s.Headers.hasDate() { return false } sig, err := s.calculateSignature(key, r) if err != nil { return false } return subtle.ConstantTimeCompare([]byte(s.Signature), []byte(sig)) == 1 }
go
func (s Signature) IsValid(key string, r *http.Request) bool { if !s.Headers.hasDate() { return false } sig, err := s.calculateSignature(key, r) if err != nil { return false } return subtle.ConstantTimeCompare([]byte(s.Signature), []byte(sig)) == 1 }
[ "func", "(", "s", "Signature", ")", "IsValid", "(", "key", "string", ",", "r", "*", "http", ".", "Request", ")", "bool", "{", "if", "!", "s", ".", "Headers", ".", "hasDate", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "sig", ",", "err", ...
// IsValid validates this signature for the given key
[ "IsValid", "validates", "this", "signature", "for", "the", "given", "key" ]
88528bf4ca7e0268c559d30cfa8825208313b3c0
https://github.com/99designs/httpsignatures-go/blob/88528bf4ca7e0268c559d30cfa8825208313b3c0/signature.go#L135-L146
142,195
qor/widget
scope.go
ToParam
func (scope *Scope) ToParam() string { if scope.Param != "" { return scope.Param } return utils.ToParamString(scope.Name) }
go
func (scope *Scope) ToParam() string { if scope.Param != "" { return scope.Param } return utils.ToParamString(scope.Name) }
[ "func", "(", "scope", "*", "Scope", ")", "ToParam", "(", ")", "string", "{", "if", "scope", ".", "Param", "!=", "\"", "\"", "{", "return", "scope", ".", "Param", "\n", "}", "\n", "return", "utils", ".", "ToParamString", "(", "scope", ".", "Name", "...
// ToParam generate param for scope
[ "ToParam", "generate", "param", "for", "scope" ]
e280f6f166153605be035918fb42660b1d0e7e0b
https://github.com/qor/widget/blob/e280f6f166153605be035918fb42660b1d0e7e0b/scope.go#L15-L20
142,196
qor/widget
render.go
Render
func (widgets *Widgets) Render(widgetName string, widgetGroupName string) template.HTML { return widgets.NewContext(nil).Render(widgetName, widgetGroupName) }
go
func (widgets *Widgets) Render(widgetName string, widgetGroupName string) template.HTML { return widgets.NewContext(nil).Render(widgetName, widgetGroupName) }
[ "func", "(", "widgets", "*", "Widgets", ")", "Render", "(", "widgetName", "string", ",", "widgetGroupName", "string", ")", "template", ".", "HTML", "{", "return", "widgets", ".", "NewContext", "(", "nil", ")", ".", "Render", "(", "widgetName", ",", "widget...
// Render find widget by name, render it based on current context
[ "Render", "find", "widget", "by", "name", "render", "it", "based", "on", "current", "context" ]
e280f6f166153605be035918fb42660b1d0e7e0b
https://github.com/qor/widget/blob/e280f6f166153605be035918fb42660b1d0e7e0b/render.go#L13-L15
142,197
qor/widget
render.go
NewContext
func (widgets *Widgets) NewContext(context *Context) *Context { if context == nil { context = &Context{} } if context.DB == nil { context.DB = widgets.Config.DB } if context.Options == nil { context.Options = map[string]interface{}{} } if context.FuncMaps == nil { context.FuncMaps = template.FuncMap{}...
go
func (widgets *Widgets) NewContext(context *Context) *Context { if context == nil { context = &Context{} } if context.DB == nil { context.DB = widgets.Config.DB } if context.Options == nil { context.Options = map[string]interface{}{} } if context.FuncMaps == nil { context.FuncMaps = template.FuncMap{}...
[ "func", "(", "widgets", "*", "Widgets", ")", "NewContext", "(", "context", "*", "Context", ")", "*", "Context", "{", "if", "context", "==", "nil", "{", "context", "=", "&", "Context", "{", "}", "\n", "}", "\n\n", "if", "context", ".", "DB", "==", "...
// NewContext create new context for widgets
[ "NewContext", "create", "new", "context", "for", "widgets" ]
e280f6f166153605be035918fb42660b1d0e7e0b
https://github.com/qor/widget/blob/e280f6f166153605be035918fb42660b1d0e7e0b/render.go#L18-L43
142,198
qor/widget
render.go
Funcs
func (context *Context) Funcs(funcMaps template.FuncMap) *Context { if context.FuncMaps == nil { context.FuncMaps = template.FuncMap{} } for key, fc := range funcMaps { context.FuncMaps[key] = fc } return context }
go
func (context *Context) Funcs(funcMaps template.FuncMap) *Context { if context.FuncMaps == nil { context.FuncMaps = template.FuncMap{} } for key, fc := range funcMaps { context.FuncMaps[key] = fc } return context }
[ "func", "(", "context", "*", "Context", ")", "Funcs", "(", "funcMaps", "template", ".", "FuncMap", ")", "*", "Context", "{", "if", "context", ".", "FuncMaps", "==", "nil", "{", "context", ".", "FuncMaps", "=", "template", ".", "FuncMap", "{", "}", "\n"...
// Funcs return view functions map
[ "Funcs", "return", "view", "functions", "map" ]
e280f6f166153605be035918fb42660b1d0e7e0b
https://github.com/qor/widget/blob/e280f6f166153605be035918fb42660b1d0e7e0b/render.go#L46-L56
142,199
qor/widget
render.go
FuncMap
func (context *Context) FuncMap() template.FuncMap { funcMap := template.FuncMap{} funcMap["render_widget"] = func(widgetName string, widgetGroupName ...string) template.HTML { var groupName string if len(widgetGroupName) == 0 { groupName = "" } else { groupName = widgetGroupName[0] } return context....
go
func (context *Context) FuncMap() template.FuncMap { funcMap := template.FuncMap{} funcMap["render_widget"] = func(widgetName string, widgetGroupName ...string) template.HTML { var groupName string if len(widgetGroupName) == 0 { groupName = "" } else { groupName = widgetGroupName[0] } return context....
[ "func", "(", "context", "*", "Context", ")", "FuncMap", "(", ")", "template", ".", "FuncMap", "{", "funcMap", ":=", "template", ".", "FuncMap", "{", "}", "\n\n", "funcMap", "[", "\"", "\"", "]", "=", "func", "(", "widgetName", "string", ",", "widgetGro...
// FuncMap return funcmap
[ "FuncMap", "return", "funcmap" ]
e280f6f166153605be035918fb42660b1d0e7e0b
https://github.com/qor/widget/blob/e280f6f166153605be035918fb42660b1d0e7e0b/render.go#L59-L73