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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
146,400 | piotrkowalczuk/ntypes | ntypes.go | Uint32Or | func (u *Uint32) Uint32Or(or uint32) uint32 {
if u == nil {
return or
}
if !u.Valid {
return or
}
return u.Uint32
} | go | func (u *Uint32) Uint32Or(or uint32) uint32 {
if u == nil {
return or
}
if !u.Valid {
return or
}
return u.Uint32
} | [
"func",
"(",
"u",
"*",
"Uint32",
")",
"Uint32Or",
"(",
"or",
"uint32",
")",
"uint32",
"{",
"if",
"u",
"==",
"nil",
"{",
"return",
"or",
"\n",
"}",
"\n",
"if",
"!",
"u",
".",
"Valid",
"{",
"return",
"or",
"\n",
"}",
"\n\n",
"return",
"u",
".",
... | // Uint32Or returns given uint32 value if receiver is nil or invalid. | [
"Uint32Or",
"returns",
"given",
"uint32",
"value",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L472-L481 |
146,401 | piotrkowalczuk/ntypes | ntypes.go | Uint32ArrayOr | func (ua *Uint32Array) Uint32ArrayOr(or []uint32) []uint32 {
switch {
case ua == nil:
return or
case !ua.Valid:
return or
default:
return ua.Uint32Array
}
} | go | func (ua *Uint32Array) Uint32ArrayOr(or []uint32) []uint32 {
switch {
case ua == nil:
return or
case !ua.Valid:
return or
default:
return ua.Uint32Array
}
} | [
"func",
"(",
"ua",
"*",
"Uint32Array",
")",
"Uint32ArrayOr",
"(",
"or",
"[",
"]",
"uint32",
")",
"[",
"]",
"uint32",
"{",
"switch",
"{",
"case",
"ua",
"==",
"nil",
":",
"return",
"or",
"\n",
"case",
"!",
"ua",
".",
"Valid",
":",
"return",
"or",
"... | // Uint32ArrayOr returns given slice if receiver is nil or invalid. | [
"Uint32ArrayOr",
"returns",
"given",
"slice",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L570-L579 |
146,402 | piotrkowalczuk/ntypes | ntypes.go | Uint64Or | func (u *Uint64) Uint64Or(or uint64) uint64 {
if u == nil {
return or
}
if !u.Valid {
return or
}
return u.Uint64
} | go | func (u *Uint64) Uint64Or(or uint64) uint64 {
if u == nil {
return or
}
if !u.Valid {
return or
}
return u.Uint64
} | [
"func",
"(",
"u",
"*",
"Uint64",
")",
"Uint64Or",
"(",
"or",
"uint64",
")",
"uint64",
"{",
"if",
"u",
"==",
"nil",
"{",
"return",
"or",
"\n",
"}",
"\n",
"if",
"!",
"u",
".",
"Valid",
"{",
"return",
"or",
"\n",
"}",
"\n\n",
"return",
"u",
".",
... | // Uint64Or returns given uint64 value if receiver is nil or invalid. | [
"Uint64Or",
"returns",
"given",
"uint64",
"value",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L587-L596 |
146,403 | piotrkowalczuk/ntypes | ntypes.go | Uint64ArrayOr | func (ua *Uint64Array) Uint64ArrayOr(or []uint64) []uint64 {
switch {
case ua == nil:
return or
case !ua.Valid:
return or
default:
return ua.Uint64Array
}
} | go | func (ua *Uint64Array) Uint64ArrayOr(or []uint64) []uint64 {
switch {
case ua == nil:
return or
case !ua.Valid:
return or
default:
return ua.Uint64Array
}
} | [
"func",
"(",
"ua",
"*",
"Uint64Array",
")",
"Uint64ArrayOr",
"(",
"or",
"[",
"]",
"uint64",
")",
"[",
"]",
"uint64",
"{",
"switch",
"{",
"case",
"ua",
"==",
"nil",
":",
"return",
"or",
"\n",
"case",
"!",
"ua",
".",
"Valid",
":",
"return",
"or",
"... | // Uint64ArrayOr returns given slice if receiver is nil or invalid. | [
"Uint64ArrayOr",
"returns",
"given",
"slice",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L643-L652 |
146,404 | piotrkowalczuk/ntypes | ntypes.go | Float32Or | func (f *Float32) Float32Or(or float32) float32 {
if f == nil {
return or
}
if !f.Valid {
return or
}
return f.Float32
} | go | func (f *Float32) Float32Or(or float32) float32 {
if f == nil {
return or
}
if !f.Valid {
return or
}
return f.Float32
} | [
"func",
"(",
"f",
"*",
"Float32",
")",
"Float32Or",
"(",
"or",
"float32",
")",
"float32",
"{",
"if",
"f",
"==",
"nil",
"{",
"return",
"or",
"\n",
"}",
"\n",
"if",
"!",
"f",
".",
"Valid",
"{",
"return",
"or",
"\n",
"}",
"\n\n",
"return",
"f",
".... | // Float32Or returns given Float32 value if receiver is nil or invalid. | [
"Float32Or",
"returns",
"given",
"Float32",
"value",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L660-L669 |
146,405 | piotrkowalczuk/ntypes | ntypes.go | Float32ArrayOr | func (fa *Float32Array) Float32ArrayOr(or []float32) []float32 {
switch {
case fa == nil:
return or
case !fa.Valid:
return or
default:
return fa.Float32Array
}
} | go | func (fa *Float32Array) Float32ArrayOr(or []float32) []float32 {
switch {
case fa == nil:
return or
case !fa.Valid:
return or
default:
return fa.Float32Array
}
} | [
"func",
"(",
"fa",
"*",
"Float32Array",
")",
"Float32ArrayOr",
"(",
"or",
"[",
"]",
"float32",
")",
"[",
"]",
"float32",
"{",
"switch",
"{",
"case",
"fa",
"==",
"nil",
":",
"return",
"or",
"\n",
"case",
"!",
"fa",
".",
"Valid",
":",
"return",
"or",... | // Float32ArrayOr returns given slice if receiver is nil or invalid. | [
"Float32ArrayOr",
"returns",
"given",
"slice",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L749-L758 |
146,406 | piotrkowalczuk/ntypes | ntypes.go | Float64Or | func (f *Float64) Float64Or(or float64) float64 {
if f == nil {
return or
}
if !f.Valid {
return or
}
return f.Float64
} | go | func (f *Float64) Float64Or(or float64) float64 {
if f == nil {
return or
}
if !f.Valid {
return or
}
return f.Float64
} | [
"func",
"(",
"f",
"*",
"Float64",
")",
"Float64Or",
"(",
"or",
"float64",
")",
"float64",
"{",
"if",
"f",
"==",
"nil",
"{",
"return",
"or",
"\n",
"}",
"\n",
"if",
"!",
"f",
".",
"Valid",
"{",
"return",
"or",
"\n",
"}",
"\n\n",
"return",
"f",
".... | // Float64Or returns given float64 value if receiver is nil or invalid. | [
"Float64Or",
"returns",
"given",
"float64",
"value",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L766-L775 |
146,407 | piotrkowalczuk/ntypes | ntypes.go | Float64ArrayOr | func (fa *Float64Array) Float64ArrayOr(or []float64) []float64 {
switch {
case fa == nil:
return or
case !fa.Valid:
return or
default:
return fa.Float64Array
}
} | go | func (fa *Float64Array) Float64ArrayOr(or []float64) []float64 {
switch {
case fa == nil:
return or
case !fa.Valid:
return or
default:
return fa.Float64Array
}
} | [
"func",
"(",
"fa",
"*",
"Float64Array",
")",
"Float64ArrayOr",
"(",
"or",
"[",
"]",
"float64",
")",
"[",
"]",
"float64",
"{",
"switch",
"{",
"case",
"fa",
"==",
"nil",
":",
"return",
"or",
"\n",
"case",
"!",
"fa",
".",
"Valid",
":",
"return",
"or",... | // Float64ArrayOr returns given slice if receiver is nil or invalid. | [
"Float64ArrayOr",
"returns",
"given",
"slice",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L872-L881 |
146,408 | piotrkowalczuk/ntypes | ntypes.go | BoolOr | func (b *Bool) BoolOr(or bool) bool {
if b == nil {
return or
}
if !b.Valid {
return or
}
return b.Bool
} | go | func (b *Bool) BoolOr(or bool) bool {
if b == nil {
return or
}
if !b.Valid {
return or
}
return b.Bool
} | [
"func",
"(",
"b",
"*",
"Bool",
")",
"BoolOr",
"(",
"or",
"bool",
")",
"bool",
"{",
"if",
"b",
"==",
"nil",
"{",
"return",
"or",
"\n",
"}",
"\n",
"if",
"!",
"b",
".",
"Valid",
"{",
"return",
"or",
"\n",
"}",
"\n\n",
"return",
"b",
".",
"Bool",... | // BoolOr returns given bool value if receiver is nil or invalid. | [
"BoolOr",
"returns",
"given",
"bool",
"value",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L894-L903 |
146,409 | piotrkowalczuk/ntypes | ntypes.go | BoolArrayOr | func (ba *BoolArray) BoolArrayOr(or []bool) []bool {
switch {
case ba == nil:
return or
case !ba.Valid:
return or
default:
return ba.BoolArray
}
} | go | func (ba *BoolArray) BoolArrayOr(or []bool) []bool {
switch {
case ba == nil:
return or
case !ba.Valid:
return or
default:
return ba.BoolArray
}
} | [
"func",
"(",
"ba",
"*",
"BoolArray",
")",
"BoolArrayOr",
"(",
"or",
"[",
"]",
"bool",
")",
"[",
"]",
"bool",
"{",
"switch",
"{",
"case",
"ba",
"==",
"nil",
":",
"return",
"or",
"\n",
"case",
"!",
"ba",
".",
"Valid",
":",
"return",
"or",
"\n",
"... | // BoolArrayOr returns given slice if receiver is nil or invalid. | [
"BoolArrayOr",
"returns",
"given",
"slice",
"if",
"receiver",
"is",
"nil",
"or",
"invalid",
"."
] | 15ae4dd32dbf658695648fdc52750c9c73223b71 | https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L1000-L1009 |
146,410 | grd/stat | absdev.go | AbsdevMean | func AbsdevMean(data Interface, mean float64) float64 {
var sum float64
Len := data.Len()
// the sum of the absolute deviations
for i := 0; i < Len; i++ {
sum += math.Abs(data.Get(i) - mean)
}
return sum / float64(Len)
} | go | func AbsdevMean(data Interface, mean float64) float64 {
var sum float64
Len := data.Len()
// the sum of the absolute deviations
for i := 0; i < Len; i++ {
sum += math.Abs(data.Get(i) - mean)
}
return sum / float64(Len)
} | [
"func",
"AbsdevMean",
"(",
"data",
"Interface",
",",
"mean",
"float64",
")",
"float64",
"{",
"var",
"sum",
"float64",
"\n",
"Len",
":=",
"data",
".",
"Len",
"(",
")",
"\n\n",
"// the sum of the absolute deviations ",
"for",
"i",
":=",
"0",
";",
"i",
"<",
... | // AbsdevMean finds the absolute deviation of the data interface | [
"AbsdevMean",
"finds",
"the",
"absolute",
"deviation",
"of",
"the",
"data",
"interface"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/absdev.go#L33-L43 |
146,411 | grd/stat | minmax.go | Max | func Max(data Interface) (max float64, max_index int) {
Len := data.Len()
max = data.Get(0)
for i := 0; i < Len; i++ {
xi := data.Get(i)
if xi > max {
max = xi
max_index = i
}
if math.IsNaN(xi) {
max = xi
max_index = i
return
}
}
return
} | go | func Max(data Interface) (max float64, max_index int) {
Len := data.Len()
max = data.Get(0)
for i := 0; i < Len; i++ {
xi := data.Get(i)
if xi > max {
max = xi
max_index = i
}
if math.IsNaN(xi) {
max = xi
max_index = i
return
}
}
return
} | [
"func",
"Max",
"(",
"data",
"Interface",
")",
"(",
"max",
"float64",
",",
"max_index",
"int",
")",
"{",
"Len",
":=",
"data",
".",
"Len",
"(",
")",
"\n",
"max",
"=",
"data",
".",
"Get",
"(",
"0",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"... | // Max finds the first largest member and the members position within the data | [
"Max",
"finds",
"the",
"first",
"largest",
"member",
"and",
"the",
"members",
"position",
"within",
"the",
"data"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/minmax.go#L28-L48 |
146,412 | grd/stat | minmax.go | Min | func Min(data Interface) (min float64, min_index int) {
Len := data.Len()
min = data.Get(0)
for i := 0; i < Len; i++ {
xi := data.Get(i)
if xi < min {
min = xi
min_index = i
}
if math.IsNaN(xi) {
min = xi
min_index = i
return
}
}
return
} | go | func Min(data Interface) (min float64, min_index int) {
Len := data.Len()
min = data.Get(0)
for i := 0; i < Len; i++ {
xi := data.Get(i)
if xi < min {
min = xi
min_index = i
}
if math.IsNaN(xi) {
min = xi
min_index = i
return
}
}
return
} | [
"func",
"Min",
"(",
"data",
"Interface",
")",
"(",
"min",
"float64",
",",
"min_index",
"int",
")",
"{",
"Len",
":=",
"data",
".",
"Len",
"(",
")",
"\n",
"min",
"=",
"data",
".",
"Get",
"(",
"0",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"... | // Min finds the first smallest member and the members position within the data | [
"Min",
"finds",
"the",
"first",
"smallest",
"member",
"and",
"the",
"members",
"position",
"within",
"the",
"data"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/minmax.go#L51-L71 |
146,413 | grd/stat | minmax.go | Minmax | func Minmax(data Interface) (min float64, min_index int, max float64, max_index int) {
Len := data.Len()
min = data.Get(0)
max = data.Get(0)
for i := 0; i < Len; i++ {
xi := data.Get(i)
if xi < min {
min = xi
min_index = i
}
if xi > max {
max = xi
max_index = i
}
if math.IsNaN(xi) {
m... | go | func Minmax(data Interface) (min float64, min_index int, max float64, max_index int) {
Len := data.Len()
min = data.Get(0)
max = data.Get(0)
for i := 0; i < Len; i++ {
xi := data.Get(i)
if xi < min {
min = xi
min_index = i
}
if xi > max {
max = xi
max_index = i
}
if math.IsNaN(xi) {
m... | [
"func",
"Minmax",
"(",
"data",
"Interface",
")",
"(",
"min",
"float64",
",",
"min_index",
"int",
",",
"max",
"float64",
",",
"max_index",
"int",
")",
"{",
"Len",
":=",
"data",
".",
"Len",
"(",
")",
"\n",
"min",
"=",
"data",
".",
"Get",
"(",
"0",
... | // Minmax finds the first smallest and largest members and
// the members positions within the data | [
"Minmax",
"finds",
"the",
"first",
"smallest",
"and",
"largest",
"members",
"and",
"the",
"members",
"positions",
"within",
"the",
"data"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/minmax.go#L75-L103 |
146,414 | dotcypress/phonetics | soundex.go | EncodeSoundex | func EncodeSoundex(word string) string {
if word == "" {
return "0000"
}
input := strings.ToLower(word)
result := strings.ToUpper(input[0:1])
code := ""
lastCode := ""
for _, rune := range input[1:] {
switch rune {
case 'b', 'f', 'p', 'v':
code = "1"
case 'c', 'g', 'j', 'k', 'q', 's', 'x',... | go | func EncodeSoundex(word string) string {
if word == "" {
return "0000"
}
input := strings.ToLower(word)
result := strings.ToUpper(input[0:1])
code := ""
lastCode := ""
for _, rune := range input[1:] {
switch rune {
case 'b', 'f', 'p', 'v':
code = "1"
case 'c', 'g', 'j', 'k', 'q', 's', 'x',... | [
"func",
"EncodeSoundex",
"(",
"word",
"string",
")",
"string",
"{",
"if",
"word",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"input",
":=",
"strings",
".",
"ToLower",
"(",
"word",
")",
"\n",
"result",
":=",
"strings",
".",
"ToUpper... | // EncodeSoundex is a function to encode string with Soundex algorithm.
// Soundex is a phonetic algorithm for indexing names by sound, as pronounced in English. | [
"EncodeSoundex",
"is",
"a",
"function",
"to",
"encode",
"string",
"with",
"Soundex",
"algorithm",
".",
"Soundex",
"is",
"a",
"phonetic",
"algorithm",
"for",
"indexing",
"names",
"by",
"sound",
"as",
"pronounced",
"in",
"English",
"."
] | 5cea56e8d200eb3a864ac9b07225f9175e7030be | https://github.com/dotcypress/phonetics/blob/5cea56e8d200eb3a864ac9b07225f9175e7030be/soundex.go#L13-L45 |
146,415 | dotcypress/phonetics | soundex.go | DifferenceSoundex | func DifferenceSoundex(word1, word2 string) int {
sum := differenceSoundex(word1, word2) + differenceSoundex(word2, word1)
if sum == 0 {
return 0
}
return sum / 2
} | go | func DifferenceSoundex(word1, word2 string) int {
sum := differenceSoundex(word1, word2) + differenceSoundex(word2, word1)
if sum == 0 {
return 0
}
return sum / 2
} | [
"func",
"DifferenceSoundex",
"(",
"word1",
",",
"word2",
"string",
")",
"int",
"{",
"sum",
":=",
"differenceSoundex",
"(",
"word1",
",",
"word2",
")",
"+",
"differenceSoundex",
"(",
"word2",
",",
"word1",
")",
"\n",
"if",
"sum",
"==",
"0",
"{",
"return",... | // DifferenceSoundex is a function to calculate difference between two strings with Soundex algorithm.
// Function returns a ranking on how similar two words are in percents. | [
"DifferenceSoundex",
"is",
"a",
"function",
"to",
"calculate",
"difference",
"between",
"two",
"strings",
"with",
"Soundex",
"algorithm",
".",
"Function",
"returns",
"a",
"ranking",
"on",
"how",
"similar",
"two",
"words",
"are",
"in",
"percents",
"."
] | 5cea56e8d200eb3a864ac9b07225f9175e7030be | https://github.com/dotcypress/phonetics/blob/5cea56e8d200eb3a864ac9b07225f9175e7030be/soundex.go#L49-L55 |
146,416 | grd/stat | wabsdev.go | WAbsdevMean | func WAbsdevMean(w, data Interface, wmean float64) (wabsdev float64) {
var W float64
Len := data.Len()
// calculate the sum of the absolute deviations
for i := 0; i < Len; i++ {
wi := w.Get(i)
if wi > 0 {
delta := math.Abs(data.Get(i) - wmean)
W += wi
wabsdev += (delta - wabsdev) * (wi / W)
}
}
... | go | func WAbsdevMean(w, data Interface, wmean float64) (wabsdev float64) {
var W float64
Len := data.Len()
// calculate the sum of the absolute deviations
for i := 0; i < Len; i++ {
wi := w.Get(i)
if wi > 0 {
delta := math.Abs(data.Get(i) - wmean)
W += wi
wabsdev += (delta - wabsdev) * (wi / W)
}
}
... | [
"func",
"WAbsdevMean",
"(",
"w",
",",
"data",
"Interface",
",",
"wmean",
"float64",
")",
"(",
"wabsdev",
"float64",
")",
"{",
"var",
"W",
"float64",
"\n",
"Len",
":=",
"data",
".",
"Len",
"(",
")",
"\n\n",
"// calculate the sum of the absolute deviations",
"... | // WAbsdevMean calculates the weighted absolute deviation of a dataset | [
"WAbsdevMean",
"calculates",
"the",
"weighted",
"absolute",
"deviation",
"of",
"a",
"dataset"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/wabsdev.go#L33-L50 |
146,417 | grd/stat | variance.go | TssMean | func TssMean(data Interface, mean float64) (res float64) {
// find the sum of the squares
n := data.Len()
for i := 0; i < n; i++ {
delta := data.Get(i) - mean
res += delta * delta
}
return
} | go | func TssMean(data Interface, mean float64) (res float64) {
// find the sum of the squares
n := data.Len()
for i := 0; i < n; i++ {
delta := data.Get(i) - mean
res += delta * delta
}
return
} | [
"func",
"TssMean",
"(",
"data",
"Interface",
",",
"mean",
"float64",
")",
"(",
"res",
"float64",
")",
"{",
"// find the sum of the squares",
"n",
":=",
"data",
".",
"Len",
"(",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"... | // TssMean takes a dataset and finds the sum of squares about the mean | [
"TssMean",
"takes",
"a",
"dataset",
"and",
"finds",
"the",
"sum",
"of",
"squares",
"about",
"the",
"mean"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/variance.go#L70-L80 |
146,418 | grd/stat | wvariance.go | WTssMean | func WTssMean(w, data Interface, wmean float64) (res float64) {
// find the sum of the squares
n := data.Len()
for i := 0; i < n; i++ {
wi := w.Get(i)
if wi > 0 {
delta := data.Get(i) - wmean
res += wi * delta * delta
}
}
return
} | go | func WTssMean(w, data Interface, wmean float64) (res float64) {
// find the sum of the squares
n := data.Len()
for i := 0; i < n; i++ {
wi := w.Get(i)
if wi > 0 {
delta := data.Get(i) - wmean
res += wi * delta * delta
}
}
return
} | [
"func",
"WTssMean",
"(",
"w",
",",
"data",
"Interface",
",",
"wmean",
"float64",
")",
"(",
"res",
"float64",
")",
"{",
"// find the sum of the squares",
"n",
":=",
"data",
".",
"Len",
"(",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
... | // WTssMean takes a dataset and finds the weighted sum of squares about wmean | [
"WTssMean",
"takes",
"a",
"dataset",
"and",
"finds",
"the",
"weighted",
"sum",
"of",
"squares",
"about",
"wmean"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/wvariance.go#L97-L111 |
146,419 | grd/stat | covariance.go | covariance | func covariance(data1, data2 Interface, mean1, mean2 float64) (res float64) {
// calculate the sum of the squares
n := data1.Len()
for i := 0; i < n; i++ {
delta1 := (data1.Get(i) - mean1)
delta2 := (data2.Get(i) - mean2)
res += (delta1*delta2 - res) / float64(i+1)
}
return
} | go | func covariance(data1, data2 Interface, mean1, mean2 float64) (res float64) {
// calculate the sum of the squares
n := data1.Len()
for i := 0; i < n; i++ {
delta1 := (data1.Get(i) - mean1)
delta2 := (data2.Get(i) - mean2)
res += (delta1*delta2 - res) / float64(i+1)
}
return
} | [
"func",
"covariance",
"(",
"data1",
",",
"data2",
"Interface",
",",
"mean1",
",",
"mean2",
"float64",
")",
"(",
"res",
"float64",
")",
"{",
"// calculate the sum of the squares",
"n",
":=",
"data1",
".",
"Len",
"(",
")",
"\n",
"for",
"i",
":=",
"0",
";",... | // takes a dataset and calculates the covariance | [
"takes",
"a",
"dataset",
"and",
"calculates",
"the",
"covariance"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/covariance.go#L28-L37 |
146,420 | grd/stat | skew.go | SkewMeanSd | func SkewMeanSd(data Interface, mean, sd float64) (skew float64) {
Len := data.Len()
for i := 0; i < Len; i++ {
x := (data.Get(i) - mean) / sd
skew += (x*x*x - skew) / float64(i+1)
}
return
} | go | func SkewMeanSd(data Interface, mean, sd float64) (skew float64) {
Len := data.Len()
for i := 0; i < Len; i++ {
x := (data.Get(i) - mean) / sd
skew += (x*x*x - skew) / float64(i+1)
}
return
} | [
"func",
"SkewMeanSd",
"(",
"data",
"Interface",
",",
"mean",
",",
"sd",
"float64",
")",
"(",
"skew",
"float64",
")",
"{",
"Len",
":=",
"data",
".",
"Len",
"(",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"Len",
";",
"i",
"++",
"{",
"x",
... | // SkewMeanSd calculates the skewness of a dataset | [
"SkewMeanSd",
"calculates",
"the",
"skewness",
"of",
"a",
"dataset"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/skew.go#L30-L38 |
146,421 | grd/stat | wkurtosis.go | WKurtosisMeanSd | func WKurtosisMeanSd(w, data Interface, wmean, wsd float64) float64 {
var wavg, W float64
Len := data.Len()
for i := 0; i < Len; i++ {
wi := w.Get(i)
if wi > 0 {
x := (data.Get(i) - wmean) / wsd
W += wi
wavg += (x*x*x*x - wavg) * (wi / W)
}
}
return wavg - 3.0 // makes kurtosis zero for a Gaussi... | go | func WKurtosisMeanSd(w, data Interface, wmean, wsd float64) float64 {
var wavg, W float64
Len := data.Len()
for i := 0; i < Len; i++ {
wi := w.Get(i)
if wi > 0 {
x := (data.Get(i) - wmean) / wsd
W += wi
wavg += (x*x*x*x - wavg) * (wi / W)
}
}
return wavg - 3.0 // makes kurtosis zero for a Gaussi... | [
"func",
"WKurtosisMeanSd",
"(",
"w",
",",
"data",
"Interface",
",",
"wmean",
",",
"wsd",
"float64",
")",
"float64",
"{",
"var",
"wavg",
",",
"W",
"float64",
"\n",
"Len",
":=",
"data",
".",
"Len",
"(",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
... | // WKurtosisMean calculates the kurtosis of a dataset | [
"WKurtosisMean",
"calculates",
"the",
"kurtosis",
"of",
"a",
"dataset"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/wkurtosis.go#L30-L46 |
146,422 | gravityblast/go-base62 | base62.go | Encode | func Encode(number int) string {
if number == 0 {
return string(alphabet[0])
}
chars := make([]byte, 0)
length := len(alphabet)
for number > 0 {
result := number / length
remainder := number % length
chars = append(chars, alphabet[remainder])
number = result
}
for i, j := 0, ... | go | func Encode(number int) string {
if number == 0 {
return string(alphabet[0])
}
chars := make([]byte, 0)
length := len(alphabet)
for number > 0 {
result := number / length
remainder := number % length
chars = append(chars, alphabet[remainder])
number = result
}
for i, j := 0, ... | [
"func",
"Encode",
"(",
"number",
"int",
")",
"string",
"{",
"if",
"number",
"==",
"0",
"{",
"return",
"string",
"(",
"alphabet",
"[",
"0",
"]",
")",
"\n",
"}",
"\n\n",
"chars",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
")",
"\n\n",
"length",... | // converts number to base62 | [
"converts",
"number",
"to",
"base62"
] | d5f2747573ce21beebdd18dfafb88093713aa45e | https://github.com/gravityblast/go-base62/blob/d5f2747573ce21beebdd18dfafb88093713aa45e/base62.go#L13-L34 |
146,423 | gravityblast/go-base62 | base62.go | Decode | func Decode(token string) int {
number := 0
idx := 0.0
chars := []byte(alphabet)
charsLength := float64(len(chars))
tokenLength := float64(len(token))
for _, c := range []byte(token) {
power := tokenLength - (idx + 1)
index := bytes.IndexByte(chars, c)
number += index * int(math.Pow(charsL... | go | func Decode(token string) int {
number := 0
idx := 0.0
chars := []byte(alphabet)
charsLength := float64(len(chars))
tokenLength := float64(len(token))
for _, c := range []byte(token) {
power := tokenLength - (idx + 1)
index := bytes.IndexByte(chars, c)
number += index * int(math.Pow(charsL... | [
"func",
"Decode",
"(",
"token",
"string",
")",
"int",
"{",
"number",
":=",
"0",
"\n",
"idx",
":=",
"0.0",
"\n",
"chars",
":=",
"[",
"]",
"byte",
"(",
"alphabet",
")",
"\n\n",
"charsLength",
":=",
"float64",
"(",
"len",
"(",
"chars",
")",
")",
"\n",... | // converts base62 token to int | [
"converts",
"base62",
"token",
"to",
"int"
] | d5f2747573ce21beebdd18dfafb88093713aa45e | https://github.com/gravityblast/go-base62/blob/d5f2747573ce21beebdd18dfafb88093713aa45e/base62.go#L37-L53 |
146,424 | grd/stat | wskew.go | WSkewMeanSd | func WSkewMeanSd(w, data Interface, wmean, wsd float64) (wskew float64) {
var W float64
Len := data.Len()
for i := 0; i < Len; i++ {
wi := w.Get(i)
if wi > 0 {
x := (data.Get(i) - wmean) / wsd
W += wi
wskew += (x*x*x - wskew) * (wi / W)
}
}
return
} | go | func WSkewMeanSd(w, data Interface, wmean, wsd float64) (wskew float64) {
var W float64
Len := data.Len()
for i := 0; i < Len; i++ {
wi := w.Get(i)
if wi > 0 {
x := (data.Get(i) - wmean) / wsd
W += wi
wskew += (x*x*x - wskew) * (wi / W)
}
}
return
} | [
"func",
"WSkewMeanSd",
"(",
"w",
",",
"data",
"Interface",
",",
"wmean",
",",
"wsd",
"float64",
")",
"(",
"wskew",
"float64",
")",
"{",
"var",
"W",
"float64",
"\n",
"Len",
":=",
"data",
".",
"Len",
"(",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i... | // Compute the weighted skewness of a dataset | [
"Compute",
"the",
"weighted",
"skewness",
"of",
"a",
"dataset"
] | 138af3fd50123bd58e50f18bf51d0a878bad96eb | https://github.com/grd/stat/blob/138af3fd50123bd58e50f18bf51d0a878bad96eb/wskew.go#L30-L45 |
146,425 | crewjam/rfc5424 | unmarshal.go | UnmarshalBinary | func (m *Message) UnmarshalBinary(inputBuffer []byte) error {
r := bytes.NewBuffer(inputBuffer)
// RFC-5424
// SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG]
if err := m.readHeader(r); err != nil {
return err
}
if err := readSpace(r); err != nil {
return err // unreachable
}
if err := m.readStructur... | go | func (m *Message) UnmarshalBinary(inputBuffer []byte) error {
r := bytes.NewBuffer(inputBuffer)
// RFC-5424
// SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG]
if err := m.readHeader(r); err != nil {
return err
}
if err := readSpace(r); err != nil {
return err // unreachable
}
if err := m.readStructur... | [
"func",
"(",
"m",
"*",
"Message",
")",
"UnmarshalBinary",
"(",
"inputBuffer",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"bytes",
".",
"NewBuffer",
"(",
"inputBuffer",
")",
"\n\n",
"// RFC-5424",
"// SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG]",
"if"... | // UnmarshalBinary unmarshals a byte slice into a message | [
"UnmarshalBinary",
"unmarshals",
"a",
"byte",
"slice",
"into",
"a",
"message"
] | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/unmarshal.go#L28-L62 |
146,426 | crewjam/rfc5424 | unmarshal.go | readPriority | func (m *Message) readPriority(r io.RuneScanner) error {
ch, _, err := r.ReadRune()
if err != nil {
return err
}
if ch != '<' {
return badFormat("Priority")
}
rv := &bytes.Buffer{}
for {
ch, _, err := r.ReadRune()
if err != nil {
return err
}
if unicode.IsDigit(ch) {
rv.WriteRune(ch)
contin... | go | func (m *Message) readPriority(r io.RuneScanner) error {
ch, _, err := r.ReadRune()
if err != nil {
return err
}
if ch != '<' {
return badFormat("Priority")
}
rv := &bytes.Buffer{}
for {
ch, _, err := r.ReadRune()
if err != nil {
return err
}
if unicode.IsDigit(ch) {
rv.WriteRune(ch)
contin... | [
"func",
"(",
"m",
"*",
"Message",
")",
"readPriority",
"(",
"r",
"io",
".",
"RuneScanner",
")",
"error",
"{",
"ch",
",",
"_",
",",
"err",
":=",
"r",
".",
"ReadRune",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n... | // readPriority reads the PRI as defined in RFC-5424 and assigns Severity and
// Facility accordingly. | [
"readPriority",
"reads",
"the",
"PRI",
"as",
"defined",
"in",
"RFC",
"-",
"5424",
"and",
"assigns",
"Severity",
"and",
"Facility",
"accordingly",
"."
] | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/unmarshal.go#L135-L166 |
146,427 | crewjam/rfc5424 | unmarshal.go | readVersion | func (m *Message) readVersion(r io.RuneScanner) error {
ch, _, err := r.ReadRune()
if err != nil {
return err
}
if ch != '1' {
return badFormat("Version")
}
return nil
} | go | func (m *Message) readVersion(r io.RuneScanner) error {
ch, _, err := r.ReadRune()
if err != nil {
return err
}
if ch != '1' {
return badFormat("Version")
}
return nil
} | [
"func",
"(",
"m",
"*",
"Message",
")",
"readVersion",
"(",
"r",
"io",
".",
"RuneScanner",
")",
"error",
"{",
"ch",
",",
"_",
",",
"err",
":=",
"r",
".",
"ReadRune",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n"... | // readVersion reads the version string fails if it isn't `1` | [
"readVersion",
"reads",
"the",
"version",
"string",
"fails",
"if",
"it",
"isn",
"t",
"1"
] | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/unmarshal.go#L169-L178 |
146,428 | crewjam/rfc5424 | unmarshal.go | readSdParamValue | func readSdParamValue(r io.RuneScanner) (string, error) {
ch, _, err := r.ReadRune()
if err != nil {
return "", err
}
if ch != '"' {
return "", badFormat("StructuredData[].Parameters[]") // hard to reach
}
rv := &bytes.Buffer{}
for {
ch, _, err := r.ReadRune()
if err != nil {
return "", err
}
if ... | go | func readSdParamValue(r io.RuneScanner) (string, error) {
ch, _, err := r.ReadRune()
if err != nil {
return "", err
}
if ch != '"' {
return "", badFormat("StructuredData[].Parameters[]") // hard to reach
}
rv := &bytes.Buffer{}
for {
ch, _, err := r.ReadRune()
if err != nil {
return "", err
}
if ... | [
"func",
"readSdParamValue",
"(",
"r",
"io",
".",
"RuneScanner",
")",
"(",
"string",
",",
"error",
")",
"{",
"ch",
",",
"_",
",",
"err",
":=",
"r",
".",
"ReadRune",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
... | // readSdParamValue reads an PARAM-VALUE as defined by RFC-5424
// SD-PARAM = PARAM-NAME "=" %d34 PARAM-VALUE %d34
// PARAM-VALUE = UTF-8-STRING ; characters '"', '\' and ']' MUST be escaped. | [
"readSdParamValue",
"reads",
"an",
"PARAM",
"-",
"VALUE",
"as",
"defined",
"by",
"RFC",
"-",
"5424",
"SD",
"-",
"PARAM",
"=",
"PARAM",
"-",
"NAME",
"=",
"%d34",
"PARAM",
"-",
"VALUE",
"%d34",
"PARAM",
"-",
"VALUE",
"=",
"UTF",
"-",
"8",
"-",
"STRING"... | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/unmarshal.go#L379-L407 |
146,429 | crewjam/rfc5424 | unmarshal.go | readSpace | func readSpace(r io.RuneScanner) error {
ch, _, err := r.ReadRune()
if err != nil {
return err
}
if ch != ' ' {
return badFormat("expected space")
}
return nil
} | go | func readSpace(r io.RuneScanner) error {
ch, _, err := r.ReadRune()
if err != nil {
return err
}
if ch != ' ' {
return badFormat("expected space")
}
return nil
} | [
"func",
"readSpace",
"(",
"r",
"io",
".",
"RuneScanner",
")",
"error",
"{",
"ch",
",",
"_",
",",
"err",
":=",
"r",
".",
"ReadRune",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"ch",
"!=",
"' '",
"{",
... | // readSpace reads a single space | [
"readSpace",
"reads",
"a",
"single",
"space"
] | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/unmarshal.go#L410-L419 |
146,430 | crewjam/rfc5424 | message.go | AddDatum | func (m *Message) AddDatum(ID string, Name string, Value string) {
if m.StructuredData == nil {
m.StructuredData = []StructuredData{}
}
for i, sd := range m.StructuredData {
if sd.ID == ID {
sd.Parameters = append(sd.Parameters, SDParam{Name: Name, Value: Value})
m.StructuredData[i] = sd
return
}
}
... | go | func (m *Message) AddDatum(ID string, Name string, Value string) {
if m.StructuredData == nil {
m.StructuredData = []StructuredData{}
}
for i, sd := range m.StructuredData {
if sd.ID == ID {
sd.Parameters = append(sd.Parameters, SDParam{Name: Name, Value: Value})
m.StructuredData[i] = sd
return
}
}
... | [
"func",
"(",
"m",
"*",
"Message",
")",
"AddDatum",
"(",
"ID",
"string",
",",
"Name",
"string",
",",
"Value",
"string",
")",
"{",
"if",
"m",
".",
"StructuredData",
"==",
"nil",
"{",
"m",
".",
"StructuredData",
"=",
"[",
"]",
"StructuredData",
"{",
"}"... | // AddDatum adds structured data to a log message | [
"AddDatum",
"adds",
"structured",
"data",
"to",
"a",
"log",
"message"
] | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/message.go#L55-L76 |
146,431 | mailgun/log | callerinfo.go | getCallerInfo | func getCallerInfo(depth int) *CallerInfo {
if pc, filePath, lineNo, ok := runtime.Caller(depth + 1); !ok {
return &CallerInfo{"unknown_file", "unknown_path", "unknown_func", 0}
} else {
return &CallerInfo{filepath.Base(filePath), filePath, runtime.FuncForPC(pc).Name(), lineNo}
}
} | go | func getCallerInfo(depth int) *CallerInfo {
if pc, filePath, lineNo, ok := runtime.Caller(depth + 1); !ok {
return &CallerInfo{"unknown_file", "unknown_path", "unknown_func", 0}
} else {
return &CallerInfo{filepath.Base(filePath), filePath, runtime.FuncForPC(pc).Name(), lineNo}
}
} | [
"func",
"getCallerInfo",
"(",
"depth",
"int",
")",
"*",
"CallerInfo",
"{",
"if",
"pc",
",",
"filePath",
",",
"lineNo",
",",
"ok",
":=",
"runtime",
".",
"Caller",
"(",
"depth",
"+",
"1",
")",
";",
"!",
"ok",
"{",
"return",
"&",
"CallerInfo",
"{",
"\... | // getCallerInfo returns information about a certain log function invoker
// such as file name, function name and line number | [
"getCallerInfo",
"returns",
"information",
"about",
"a",
"certain",
"log",
"function",
"invoker",
"such",
"as",
"file",
"name",
"function",
"name",
"and",
"line",
"number"
] | 2f35a4607f1abf71f97f77f99b0de8493ef6f4ef | https://github.com/mailgun/log/blob/2f35a4607f1abf71f97f77f99b0de8493ef6f4ef/callerinfo.go#L34-L40 |
146,432 | mailgun/log | log.go | Init | func Init(l ...Logger) {
for _, logger := range l {
gl.loggers = append(gl.loggers, logger)
}
} | go | func Init(l ...Logger) {
for _, logger := range l {
gl.loggers = append(gl.loggers, logger)
}
} | [
"func",
"Init",
"(",
"l",
"...",
"Logger",
")",
"{",
"for",
"_",
",",
"logger",
":=",
"range",
"l",
"{",
"gl",
".",
"loggers",
"=",
"append",
"(",
"gl",
".",
"loggers",
",",
"logger",
")",
"\n",
"}",
"\n",
"}"
] | // Init initializes the logging package with the provided loggers. | [
"Init",
"initializes",
"the",
"logging",
"package",
"with",
"the",
"provided",
"loggers",
"."
] | 2f35a4607f1abf71f97f77f99b0de8493ef6f4ef | https://github.com/mailgun/log/blob/2f35a4607f1abf71f97f77f99b0de8493ef6f4ef/log.go#L54-L58 |
146,433 | mailgun/log | log.go | InitWithConfig | func InitWithConfig(configs ...Config) error {
for _, config := range configs {
l, err := NewLogger(config)
if err != nil {
return err
}
gl.loggers = append(gl.loggers, l)
}
return nil
} | go | func InitWithConfig(configs ...Config) error {
for _, config := range configs {
l, err := NewLogger(config)
if err != nil {
return err
}
gl.loggers = append(gl.loggers, l)
}
return nil
} | [
"func",
"InitWithConfig",
"(",
"configs",
"...",
"Config",
")",
"error",
"{",
"for",
"_",
",",
"config",
":=",
"range",
"configs",
"{",
"l",
",",
"err",
":=",
"NewLogger",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n"... | // InitWithConfig instantiates loggers based on the provided configs and initializes
// the package with them. | [
"InitWithConfig",
"instantiates",
"loggers",
"based",
"on",
"the",
"provided",
"configs",
"and",
"initializes",
"the",
"package",
"with",
"them",
"."
] | 2f35a4607f1abf71f97f77f99b0de8493ef6f4ef | https://github.com/mailgun/log/blob/2f35a4607f1abf71f97f77f99b0de8493ef6f4ef/log.go#L62-L71 |
146,434 | mailgun/log | log.go | NewLogger | func NewLogger(config Config) (Logger, error) {
switch config.Name {
case Console:
return NewConsoleLogger(config)
case Syslog:
return NewSysLogger(config)
case UDPLog:
return NewUDPLogger(config)
}
return nil, fmt.Errorf("unknown logger: %v", config)
} | go | func NewLogger(config Config) (Logger, error) {
switch config.Name {
case Console:
return NewConsoleLogger(config)
case Syslog:
return NewSysLogger(config)
case UDPLog:
return NewUDPLogger(config)
}
return nil, fmt.Errorf("unknown logger: %v", config)
} | [
"func",
"NewLogger",
"(",
"config",
"Config",
")",
"(",
"Logger",
",",
"error",
")",
"{",
"switch",
"config",
".",
"Name",
"{",
"case",
"Console",
":",
"return",
"NewConsoleLogger",
"(",
"config",
")",
"\n",
"case",
"Syslog",
":",
"return",
"NewSysLogger",... | // NewLogger makes a proper logger from the given configuration. | [
"NewLogger",
"makes",
"a",
"proper",
"logger",
"from",
"the",
"given",
"configuration",
"."
] | 2f35a4607f1abf71f97f77f99b0de8493ef6f4ef | https://github.com/mailgun/log/blob/2f35a4607f1abf71f97f77f99b0de8493ef6f4ef/log.go#L74-L84 |
146,435 | mailgun/log | log.go | Logfmt | func Logfmt(callDepth int, sev Severity, format string, args ...interface{}) {
gl.Logf(callDepth, sev, format, args...)
} | go | func Logfmt(callDepth int, sev Severity, format string, args ...interface{}) {
gl.Logf(callDepth, sev, format, args...)
} | [
"func",
"Logfmt",
"(",
"callDepth",
"int",
",",
"sev",
"Severity",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"gl",
".",
"Logf",
"(",
"callDepth",
",",
"sev",
",",
"format",
",",
"args",
"...",
")",
"\n",
"}"
] | // Logfmt logs a formatted message of the specified severity, marking it
// attributed to a function at the specified depth on the current goroutine
// stack. | [
"Logfmt",
"logs",
"a",
"formatted",
"message",
"of",
"the",
"specified",
"severity",
"marking",
"it",
"attributed",
"to",
"a",
"function",
"at",
"the",
"specified",
"depth",
"on",
"the",
"current",
"goroutine",
"stack",
"."
] | 2f35a4607f1abf71f97f77f99b0de8493ef6f4ef | https://github.com/mailgun/log/blob/2f35a4607f1abf71f97f77f99b0de8493ef6f4ef/log.go#L143-L145 |
146,436 | crewjam/rfc5424 | stream.go | WriteTo | func (m Message) WriteTo(w io.Writer) (int64, error) {
b, err := m.MarshalBinary()
if err != nil {
return 0, err
}
n, err := fmt.Fprintf(w, "%d %s", len(b), b)
return int64(n), err
} | go | func (m Message) WriteTo(w io.Writer) (int64, error) {
b, err := m.MarshalBinary()
if err != nil {
return 0, err
}
n, err := fmt.Fprintf(w, "%d %s", len(b), b)
return int64(n), err
} | [
"func",
"(",
"m",
"Message",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"int64",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"m",
".",
"MarshalBinary",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
... | // WriteTo writes the message to a stream of messages in the style defined
// by RFC-5425. (It does not implement the TLS stuff described in the RFC, just
// the length delimiting. | [
"WriteTo",
"writes",
"the",
"message",
"to",
"a",
"stream",
"of",
"messages",
"in",
"the",
"style",
"defined",
"by",
"RFC",
"-",
"5425",
".",
"(",
"It",
"does",
"not",
"implement",
"the",
"TLS",
"stuff",
"described",
"in",
"the",
"RFC",
"just",
"the",
... | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/stream.go#L13-L20 |
146,437 | crewjam/rfc5424 | stream.go | ReadFrom | func (m *Message) ReadFrom(r io.Reader) (int64, error) {
lengthBuf, n1, err := readUntilSpace(r)
if err != nil {
return 0, err
}
length, err := strconv.Atoi(string(lengthBuf))
if err != nil {
return 0, err
}
r2 := io.LimitReader(r, int64(length))
buf, err := ioutil.ReadAll(r2)
if err != nil {
return int6... | go | func (m *Message) ReadFrom(r io.Reader) (int64, error) {
lengthBuf, n1, err := readUntilSpace(r)
if err != nil {
return 0, err
}
length, err := strconv.Atoi(string(lengthBuf))
if err != nil {
return 0, err
}
r2 := io.LimitReader(r, int64(length))
buf, err := ioutil.ReadAll(r2)
if err != nil {
return int6... | [
"func",
"(",
"m",
"*",
"Message",
")",
"ReadFrom",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"int64",
",",
"error",
")",
"{",
"lengthBuf",
",",
"n1",
",",
"err",
":=",
"readUntilSpace",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // ReadFrom reads a single record from an RFC-5425 style stream of messages | [
"ReadFrom",
"reads",
"a",
"single",
"record",
"from",
"an",
"RFC",
"-",
"5425",
"style",
"stream",
"of",
"messages"
] | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/stream.go#L40-L62 |
146,438 | crewjam/rfc5424 | marshal.go | invalidValue | func invalidValue(property string, value interface{}) error {
return ErrInvalidValue{Property: property, Value: value}
} | go | func invalidValue(property string, value interface{}) error {
return ErrInvalidValue{Property: property, Value: value}
} | [
"func",
"invalidValue",
"(",
"property",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"ErrInvalidValue",
"{",
"Property",
":",
"property",
",",
"Value",
":",
"value",
"}",
"\n",
"}"
] | // invalidValue returns an invalid value error with the given property | [
"invalidValue",
"returns",
"an",
"invalid",
"value",
"error",
"with",
"the",
"given",
"property"
] | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/marshal.go#L28-L30 |
146,439 | crewjam/rfc5424 | marshal.go | MarshalBinary | func (m Message) MarshalBinary() ([]byte, error) {
if err := m.assertValid(); err != nil {
return nil, err
}
b := bytes.NewBuffer(nil)
fmt.Fprintf(b, "<%d>1 %s %s %s %s %s ",
m.Priority,
m.Timestamp.Format(rfc3339Micro),
nilify(m.Hostname),
nilify(m.AppName),
nilify(m.ProcessID),
nilify(m.MessageID))... | go | func (m Message) MarshalBinary() ([]byte, error) {
if err := m.assertValid(); err != nil {
return nil, err
}
b := bytes.NewBuffer(nil)
fmt.Fprintf(b, "<%d>1 %s %s %s %s %s ",
m.Priority,
m.Timestamp.Format(rfc3339Micro),
nilify(m.Hostname),
nilify(m.AppName),
nilify(m.ProcessID),
nilify(m.MessageID))... | [
"func",
"(",
"m",
"Message",
")",
"MarshalBinary",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"err",
":=",
"m",
".",
"assertValid",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"b",... | // MarshalBinary marshals the message to a byte slice, or returns an error | [
"MarshalBinary",
"marshals",
"the",
"message",
"to",
"a",
"byte",
"slice",
"or",
"returns",
"an",
"error"
] | c25bdd3a0ba2122b52eaf91798dc2e3a218668e9 | https://github.com/crewjam/rfc5424/blob/c25bdd3a0ba2122b52eaf91798dc2e3a218668e9/marshal.go#L142-L173 |
146,440 | qor/responder | responder.go | Respond | func (rep *Responder) Respond(request *http.Request) {
// get request format from url
if ext := filepath.Ext(request.URL.Path); ext != "" {
if respond, ok := rep.responds[strings.TrimPrefix(ext, ".")]; ok {
respond()
return
}
}
// get request format from Accept
for _, accept := range strings.Split(reque... | go | func (rep *Responder) Respond(request *http.Request) {
// get request format from url
if ext := filepath.Ext(request.URL.Path); ext != "" {
if respond, ok := rep.responds[strings.TrimPrefix(ext, ".")]; ok {
respond()
return
}
}
// get request format from Accept
for _, accept := range strings.Split(reque... | [
"func",
"(",
"rep",
"*",
"Responder",
")",
"Respond",
"(",
"request",
"*",
"http",
".",
"Request",
")",
"{",
"// get request format from url",
"if",
"ext",
":=",
"filepath",
".",
"Ext",
"(",
"request",
".",
"URL",
".",
"Path",
")",
";",
"ext",
"!=",
"\... | // Respond differently according to request's accepted mime type | [
"Respond",
"differently",
"according",
"to",
"request",
"s",
"accepted",
"mime",
"type"
] | b6def473574f621fee316696ad120d4fbf470826 | https://github.com/qor/responder/blob/b6def473574f621fee316696ad120d4fbf470826/responder.go#L63-L89 |
146,441 | davidlazar/go-crypto | encoding/base32/base32.go | EncodeToString | func EncodeToString(src []byte) string {
s := CompactEncoding.EncodeToString(src)
return strings.TrimRight(s, "=")
} | go | func EncodeToString(src []byte) string {
s := CompactEncoding.EncodeToString(src)
return strings.TrimRight(s, "=")
} | [
"func",
"EncodeToString",
"(",
"src",
"[",
"]",
"byte",
")",
"string",
"{",
"s",
":=",
"CompactEncoding",
".",
"EncodeToString",
"(",
"src",
")",
"\n",
"return",
"strings",
".",
"TrimRight",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // EncodeToString encodes src using CompactEncoding without padding | [
"EncodeToString",
"encodes",
"src",
"using",
"CompactEncoding",
"without",
"padding"
] | dcfb0a7ac018a248366f96bcd8a2f8c805d7b268 | https://github.com/davidlazar/go-crypto/blob/dcfb0a7ac018a248366f96bcd8a2f8c805d7b268/encoding/base32/base32.go#L20-L23 |
146,442 | davidlazar/go-crypto | secretkey/secretkey.go | Encrypt | func Encrypt(key *Key, passphrase []byte) []byte {
dst := make([]byte, EncryptedKeyLength)
copy(dst[0:32], key[:])
h := hashKey(key[:])
copy(dst[32:36], h)
k, err := scrypt.Key(passphrase, h, 1<<18, 8, 1, 64)
if err != nil {
panic(err)
}
runtime.GC()
for i := 0; i < 32; i++ {
dst[i] ^= k[i]
}
c1, _ :... | go | func Encrypt(key *Key, passphrase []byte) []byte {
dst := make([]byte, EncryptedKeyLength)
copy(dst[0:32], key[:])
h := hashKey(key[:])
copy(dst[32:36], h)
k, err := scrypt.Key(passphrase, h, 1<<18, 8, 1, 64)
if err != nil {
panic(err)
}
runtime.GC()
for i := 0; i < 32; i++ {
dst[i] ^= k[i]
}
c1, _ :... | [
"func",
"Encrypt",
"(",
"key",
"*",
"Key",
",",
"passphrase",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"EncryptedKeyLength",
")",
"\n",
"copy",
"(",
"dst",
"[",
"0",
":",
"32",
"]",
",",
"ke... | // Encrypt a secret key using BIP38-style encryption. | [
"Encrypt",
"a",
"secret",
"key",
"using",
"BIP38",
"-",
"style",
"encryption",
"."
] | dcfb0a7ac018a248366f96bcd8a2f8c805d7b268 | https://github.com/davidlazar/go-crypto/blob/dcfb0a7ac018a248366f96bcd8a2f8c805d7b268/secretkey/secretkey.go#L33-L59 |
146,443 | davidlazar/go-crypto | poly1305/poly1305.go | Reset | func (d *digest) Reset() {
k := d.key
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
d.r[0] = ((uint32(k[ 0]) | uint32(k[ 1])<<8 | uint32(k[ 2])<<16 | uint32(k[ 3])<<24) ) & 0x3ffffff
d.r[1] = ((uint32(k[ 3]) | uint32(k[ 4])<<8 | uint32(k[ 5])<<16 | uint32(k[ 6])<<24) >> 2) & 0x3ffff03
d.r[2] = ((uint32(k[ 6]) ... | go | func (d *digest) Reset() {
k := d.key
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
d.r[0] = ((uint32(k[ 0]) | uint32(k[ 1])<<8 | uint32(k[ 2])<<16 | uint32(k[ 3])<<24) ) & 0x3ffffff
d.r[1] = ((uint32(k[ 3]) | uint32(k[ 4])<<8 | uint32(k[ 5])<<16 | uint32(k[ 6])<<24) >> 2) & 0x3ffff03
d.r[2] = ((uint32(k[ 6]) ... | [
"func",
"(",
"d",
"*",
"digest",
")",
"Reset",
"(",
")",
"{",
"k",
":=",
"d",
".",
"key",
"\n\n",
"/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */",
"d",
".",
"r",
"[",
"0",
"]",
"=",
"(",
"(",
"uint32",
"(",
"k",
"[",
"0",
"]",
")",
"|",
"uint32",
... | // Reset is needed to satisfy the hash.Hash interface, but should never be
// used to authenticate a different message under the same key. | [
"Reset",
"is",
"needed",
"to",
"satisfy",
"the",
"hash",
".",
"Hash",
"interface",
"but",
"should",
"never",
"be",
"used",
"to",
"authenticate",
"a",
"different",
"message",
"under",
"the",
"same",
"key",
"."
] | dcfb0a7ac018a248366f96bcd8a2f8c805d7b268 | https://github.com/davidlazar/go-crypto/blob/dcfb0a7ac018a248366f96bcd8a2f8c805d7b268/poly1305/poly1305.go#L37-L57 |
146,444 | mkideal/pkg | netutil/packet_reader.go | NewPacketReader | func NewPacketReader(conn net.Conn, packetHandler PacketHandler) PacketReader {
return &packetReader{
id: conn.RemoteAddr().String(),
conn: conn,
packetHandler: packetHandler,
}
} | go | func NewPacketReader(conn net.Conn, packetHandler PacketHandler) PacketReader {
return &packetReader{
id: conn.RemoteAddr().String(),
conn: conn,
packetHandler: packetHandler,
}
} | [
"func",
"NewPacketReader",
"(",
"conn",
"net",
".",
"Conn",
",",
"packetHandler",
"PacketHandler",
")",
"PacketReader",
"{",
"return",
"&",
"packetReader",
"{",
"id",
":",
"conn",
".",
"RemoteAddr",
"(",
")",
".",
"String",
"(",
")",
",",
"conn",
":",
"c... | // NewPacketReader creates a PacketReader with net.Conn and PacketHandler | [
"NewPacketReader",
"creates",
"a",
"PacketReader",
"with",
"net",
".",
"Conn",
"and",
"PacketHandler"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/netutil/packet_reader.go#L33-L39 |
146,445 | mkideal/pkg | encoding/jsonx/jsonx.go | Read | func Read(r io.Reader, opts ...Option) (Node, error) {
opt := applyOptions(opts)
s := new(scanner.Scanner)
s = s.Init(r)
s.Mode = scanner.ScanIdents | scanner.ScanFloats | scanner.ScanChars | scanner.ScanStrings
if opt.supportComment {
s.Mode |= scanner.ScanComments
}
p := new(parser)
if err := p.init(s, opt)... | go | func Read(r io.Reader, opts ...Option) (Node, error) {
opt := applyOptions(opts)
s := new(scanner.Scanner)
s = s.Init(r)
s.Mode = scanner.ScanIdents | scanner.ScanFloats | scanner.ScanChars | scanner.ScanStrings
if opt.supportComment {
s.Mode |= scanner.ScanComments
}
p := new(parser)
if err := p.init(s, opt)... | [
"func",
"Read",
"(",
"r",
"io",
".",
"Reader",
",",
"opts",
"...",
"Option",
")",
"(",
"Node",
",",
"error",
")",
"{",
"opt",
":=",
"applyOptions",
"(",
"opts",
")",
"\n",
"s",
":=",
"new",
"(",
"scanner",
".",
"Scanner",
")",
"\n",
"s",
"=",
"... | // Read reads a json node from reader r | [
"Read",
"reads",
"a",
"json",
"node",
"from",
"reader",
"r"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/jsonx/jsonx.go#L77-L90 |
146,446 | mkideal/pkg | encoding/jsonx/jsonx.go | ReadBytes | func ReadBytes(data []byte, opts ...Option) (Node, error) {
return Read(bytes.NewBuffer(data), opts...)
} | go | func ReadBytes(data []byte, opts ...Option) (Node, error) {
return Read(bytes.NewBuffer(data), opts...)
} | [
"func",
"ReadBytes",
"(",
"data",
"[",
"]",
"byte",
",",
"opts",
"...",
"Option",
")",
"(",
"Node",
",",
"error",
")",
"{",
"return",
"Read",
"(",
"bytes",
".",
"NewBuffer",
"(",
"data",
")",
",",
"opts",
"...",
")",
"\n",
"}"
] | // ReadBytes reads a json node from bytes | [
"ReadBytes",
"reads",
"a",
"json",
"node",
"from",
"bytes"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/jsonx/jsonx.go#L93-L95 |
146,447 | mkideal/pkg | encoding/jsonx/jsonx.go | ReadFile | func ReadFile(filename string, opts ...Option) (Node, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
return Read(file, opts...)
} | go | func ReadFile(filename string, opts ...Option) (Node, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
return Read(file, opts...)
} | [
"func",
"ReadFile",
"(",
"filename",
"string",
",",
"opts",
"...",
"Option",
")",
"(",
"Node",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"... | // ReadFile reads a json node from file | [
"ReadFile",
"reads",
"a",
"json",
"node",
"from",
"file"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/jsonx/jsonx.go#L98-L105 |
146,448 | mkideal/pkg | encoding/jsonx/jsonx.go | Write | func Write(w io.Writer, node Node, opts ...Option) error {
return node.output("", w, applyOptions(opts), true, true)
} | go | func Write(w io.Writer, node Node, opts ...Option) error {
return node.output("", w, applyOptions(opts), true, true)
} | [
"func",
"Write",
"(",
"w",
"io",
".",
"Writer",
",",
"node",
"Node",
",",
"opts",
"...",
"Option",
")",
"error",
"{",
"return",
"node",
".",
"output",
"(",
"\"",
"\"",
",",
"w",
",",
"applyOptions",
"(",
"opts",
")",
",",
"true",
",",
"true",
")"... | // Write writes a json node to writer w | [
"Write",
"writes",
"a",
"json",
"node",
"to",
"writer",
"w"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/jsonx/jsonx.go#L108-L110 |
146,449 | mkideal/pkg | encoding/jsonx/jsonx.go | WriteFile | func WriteFile(filename string, node Node, perm os.FileMode, opts ...Option) error {
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
if err != nil {
return err
}
defer file.Close()
return Write(file, node, opts...)
} | go | func WriteFile(filename string, node Node, perm os.FileMode, opts ...Option) error {
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
if err != nil {
return err
}
defer file.Close()
return Write(file, node, opts...)
} | [
"func",
"WriteFile",
"(",
"filename",
"string",
",",
"node",
"Node",
",",
"perm",
"os",
".",
"FileMode",
",",
"opts",
"...",
"Option",
")",
"error",
"{",
"file",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"filename",
",",
"os",
".",
"O_WRONLY",
"|... | // WriteFile writer a json node to file | [
"WriteFile",
"writer",
"a",
"json",
"node",
"to",
"file"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/jsonx/jsonx.go#L113-L120 |
146,450 | mkideal/pkg | encoding/jsonx/jsonx.go | Unmarshal | func Unmarshal(data []byte, v interface{}, opts ...Option) error {
if len(opts) == 0 {
return json.Unmarshal(data, v)
}
buf := bytes.NewBuffer(data)
node, err := Read(buf, opts...)
if err != nil {
return err
}
buf.Reset()
if err := Write(buf, node); err != nil {
return err
}
return json.Unmarshal(buf.By... | go | func Unmarshal(data []byte, v interface{}, opts ...Option) error {
if len(opts) == 0 {
return json.Unmarshal(data, v)
}
buf := bytes.NewBuffer(data)
node, err := Read(buf, opts...)
if err != nil {
return err
}
buf.Reset()
if err := Write(buf, node); err != nil {
return err
}
return json.Unmarshal(buf.By... | [
"func",
"Unmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
",",
"opts",
"...",
"Option",
")",
"error",
"{",
"if",
"len",
"(",
"opts",
")",
"==",
"0",
"{",
"return",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"v",
")",
... | // Unmarshal wraps json.Unmarshal with options | [
"Unmarshal",
"wraps",
"json",
".",
"Unmarshal",
"with",
"options"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/jsonx/jsonx.go#L123-L137 |
146,451 | mkideal/pkg | encoding/jsonx/jsonx.go | NewDecoder | func NewDecoder(r io.Reader, opts ...Option) *Decoder {
return &Decoder{
r: r,
opt: applyOptions(opts),
}
} | go | func NewDecoder(r io.Reader, opts ...Option) *Decoder {
return &Decoder{
r: r,
opt: applyOptions(opts),
}
} | [
"func",
"NewDecoder",
"(",
"r",
"io",
".",
"Reader",
",",
"opts",
"...",
"Option",
")",
"*",
"Decoder",
"{",
"return",
"&",
"Decoder",
"{",
"r",
":",
"r",
",",
"opt",
":",
"applyOptions",
"(",
"opts",
")",
",",
"}",
"\n",
"}"
] | // NewDecoder creates a decoder with reader and options | [
"NewDecoder",
"creates",
"a",
"decoder",
"with",
"reader",
"and",
"options"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/jsonx/jsonx.go#L162-L167 |
146,452 | mkideal/pkg | encoding/jsonx/jsonx.go | Decode | func (decoder *Decoder) Decode(v interface{}) error {
node, err := Read(decoder.r, decoder.opt.clone)
if err != nil {
return err
}
var buf bytes.Buffer
if err := Write(&buf, node); err != nil {
return err
}
return json.Unmarshal(buf.Bytes(), v)
} | go | func (decoder *Decoder) Decode(v interface{}) error {
node, err := Read(decoder.r, decoder.opt.clone)
if err != nil {
return err
}
var buf bytes.Buffer
if err := Write(&buf, node); err != nil {
return err
}
return json.Unmarshal(buf.Bytes(), v)
} | [
"func",
"(",
"decoder",
"*",
"Decoder",
")",
"Decode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"node",
",",
"err",
":=",
"Read",
"(",
"decoder",
".",
"r",
",",
"decoder",
".",
"opt",
".",
"clone",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Decode decodes data and stores it in the valyala pointed to by v | [
"Decode",
"decodes",
"data",
"and",
"stores",
"it",
"in",
"the",
"valyala",
"pointed",
"to",
"by",
"v"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/jsonx/jsonx.go#L170-L180 |
146,453 | mkideal/pkg | errors/errors.go | Throw | func Throw(text string) error {
if atomic.LoadInt32(&enableTrace) != 0 {
return traceError{stack: string(debug.Stack(2)) + "\n", text: text}
}
return traceError{text: text}
} | go | func Throw(text string) error {
if atomic.LoadInt32(&enableTrace) != 0 {
return traceError{stack: string(debug.Stack(2)) + "\n", text: text}
}
return traceError{text: text}
} | [
"func",
"Throw",
"(",
"text",
"string",
")",
"error",
"{",
"if",
"atomic",
".",
"LoadInt32",
"(",
"&",
"enableTrace",
")",
"!=",
"0",
"{",
"return",
"traceError",
"{",
"stack",
":",
"string",
"(",
"debug",
".",
"Stack",
"(",
"2",
")",
")",
"+",
"\"... | // Throw throws an error which contains stack information | [
"Throw",
"throws",
"an",
"error",
"which",
"contains",
"stack",
"information"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/errors/errors.go#L36-L41 |
146,454 | mkideal/pkg | errors/errors.go | Wrap | func Wrap(err error) error {
return wrapStackError{stack: string(debug.Stack(2)), err: err}
} | go | func Wrap(err error) error {
return wrapStackError{stack: string(debug.Stack(2)), err: err}
} | [
"func",
"Wrap",
"(",
"err",
"error",
")",
"error",
"{",
"return",
"wrapStackError",
"{",
"stack",
":",
"string",
"(",
"debug",
".",
"Stack",
"(",
"2",
")",
")",
",",
"err",
":",
"err",
"}",
"\n",
"}"
] | // Wrap wraps another error | [
"Wrap",
"wraps",
"another",
"error"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/errors/errors.go#L71-L73 |
146,455 | mkideal/pkg | errors/errors.go | Core | func Core(err error) error {
const maxWrapLayer = 32
c := 0
for err != nil && c < maxWrapLayer {
c++
we, ok := err.(wrappedError)
if !ok {
break
}
err = we.Core()
}
return err
} | go | func Core(err error) error {
const maxWrapLayer = 32
c := 0
for err != nil && c < maxWrapLayer {
c++
we, ok := err.(wrappedError)
if !ok {
break
}
err = we.Core()
}
return err
} | [
"func",
"Core",
"(",
"err",
"error",
")",
"error",
"{",
"const",
"maxWrapLayer",
"=",
"32",
"\n",
"c",
":=",
"0",
"\n",
"for",
"err",
"!=",
"nil",
"&&",
"c",
"<",
"maxWrapLayer",
"{",
"c",
"++",
"\n",
"we",
",",
"ok",
":=",
"err",
".",
"(",
"wr... | // Core returns wrapped error | [
"Core",
"returns",
"wrapped",
"error"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/errors/errors.go#L76-L88 |
146,456 | mkideal/pkg | storage/entity.go | ToStringKeys | func ToStringKeys(keys KeyList, filter func(string) bool) StringKeys {
if keys == nil {
return nil
}
if strKeys, ok := keys.(StringKeys); ok {
return strKeys
}
strs := make([]string, 0, keys.Len())
for i := 0; i < keys.Len(); i++ {
value := typeconv.ToString(keys.Key(i))
if filter == nil || filter(value) ... | go | func ToStringKeys(keys KeyList, filter func(string) bool) StringKeys {
if keys == nil {
return nil
}
if strKeys, ok := keys.(StringKeys); ok {
return strKeys
}
strs := make([]string, 0, keys.Len())
for i := 0; i < keys.Len(); i++ {
value := typeconv.ToString(keys.Key(i))
if filter == nil || filter(value) ... | [
"func",
"ToStringKeys",
"(",
"keys",
"KeyList",
",",
"filter",
"func",
"(",
"string",
")",
"bool",
")",
"StringKeys",
"{",
"if",
"keys",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"strKeys",
",",
"ok",
":=",
"keys",
".",
"(",
"StringKe... | // ToInt64Keys convert KeyList to an StringKeys which satify filter
// all keys would be contained if filter is nil | [
"ToInt64Keys",
"convert",
"KeyList",
"to",
"an",
"StringKeys",
"which",
"satify",
"filter",
"all",
"keys",
"would",
"be",
"contained",
"if",
"filter",
"is",
"nil"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/entity.go#L54-L69 |
146,457 | mkideal/pkg | storage/entity.go | ToInt64Keys | func ToInt64Keys(keys KeyList, filter func(int64) bool) Int64Keys {
if keys == nil {
return nil
}
if int64Keys, ok := keys.(Int64Keys); ok {
return int64Keys
}
int64s := make([]int64, 0, keys.Len())
for i := 0; i < keys.Len(); i++ {
key := keys.Key(i)
if key == nil {
continue
}
var (
value int64... | go | func ToInt64Keys(keys KeyList, filter func(int64) bool) Int64Keys {
if keys == nil {
return nil
}
if int64Keys, ok := keys.(Int64Keys); ok {
return int64Keys
}
int64s := make([]int64, 0, keys.Len())
for i := 0; i < keys.Len(); i++ {
key := keys.Key(i)
if key == nil {
continue
}
var (
value int64... | [
"func",
"ToInt64Keys",
"(",
"keys",
"KeyList",
",",
"filter",
"func",
"(",
"int64",
")",
"bool",
")",
"Int64Keys",
"{",
"if",
"keys",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"int64Keys",
",",
"ok",
":=",
"keys",
".",
"(",
"Int64Keys... | // ToInt64Keys convert KeyList to an Int64Keys which satify filter
// all keys would be contained if filter is nil | [
"ToInt64Keys",
"convert",
"KeyList",
"to",
"an",
"Int64Keys",
"which",
"satify",
"filter",
"all",
"keys",
"would",
"be",
"contained",
"if",
"filter",
"is",
"nil"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/entity.go#L73-L129 |
146,458 | mkideal/pkg | expr/expr.go | GetVar | func (getter Getter) GetVar(name string) (Value, bool) {
if getter == nil {
return nilValue, false
}
v, ok := getter[name]
return v, ok
} | go | func (getter Getter) GetVar(name string) (Value, bool) {
if getter == nil {
return nilValue, false
}
v, ok := getter[name]
return v, ok
} | [
"func",
"(",
"getter",
"Getter",
")",
"GetVar",
"(",
"name",
"string",
")",
"(",
"Value",
",",
"bool",
")",
"{",
"if",
"getter",
"==",
"nil",
"{",
"return",
"nilValue",
",",
"false",
"\n",
"}",
"\n",
"v",
",",
"ok",
":=",
"getter",
"[",
"name",
"... | // GetVar gets the value of variable | [
"GetVar",
"gets",
"the",
"value",
"of",
"variable"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/expr/expr.go#L29-L35 |
146,459 | mkideal/pkg | expr/expr.go | New | func New(s string, pool *Pool) (*Expr, error) {
s = strings.TrimSpace(s)
if pool == nil {
pool = defaultPool
}
if e, ok := pool.get(s); ok {
return e, nil
}
e := new(Expr)
e.pool = pool
if err := e.parse(s); err != nil {
return nil, err
}
pool.set(s, e)
return e, nil
} | go | func New(s string, pool *Pool) (*Expr, error) {
s = strings.TrimSpace(s)
if pool == nil {
pool = defaultPool
}
if e, ok := pool.get(s); ok {
return e, nil
}
e := new(Expr)
e.pool = pool
if err := e.parse(s); err != nil {
return nil, err
}
pool.set(s, e)
return e, nil
} | [
"func",
"New",
"(",
"s",
"string",
",",
"pool",
"*",
"Pool",
")",
"(",
"*",
"Expr",
",",
"error",
")",
"{",
"s",
"=",
"strings",
".",
"TrimSpace",
"(",
"s",
")",
"\n",
"if",
"pool",
"==",
"nil",
"{",
"pool",
"=",
"defaultPool",
"\n",
"}",
"\n",... | // New creates an Expr and parses string s, pool can be nil | [
"New",
"creates",
"an",
"Expr",
"and",
"parses",
"string",
"s",
"pool",
"can",
"be",
"nil"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/expr/expr.go#L38-L53 |
146,460 | mkideal/pkg | expr/expr.go | parse | func (e *Expr) parse(s string) error {
if s == "" {
return nil
}
node, err := parser.ParseExpr(s)
if err != nil {
return err
}
e.root = node
v := &visitor{pool: e.pool}
ast.Walk(v, e.root)
return v.err
} | go | func (e *Expr) parse(s string) error {
if s == "" {
return nil
}
node, err := parser.ParseExpr(s)
if err != nil {
return err
}
e.root = node
v := &visitor{pool: e.pool}
ast.Walk(v, e.root)
return v.err
} | [
"func",
"(",
"e",
"*",
"Expr",
")",
"parse",
"(",
"s",
"string",
")",
"error",
"{",
"if",
"s",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"node",
",",
"err",
":=",
"parser",
".",
"ParseExpr",
"(",
"s",
")",
"\n",
"if",
"err",
"!... | // parse parses string s | [
"parse",
"parses",
"string",
"s"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/expr/expr.go#L56-L69 |
146,461 | mkideal/pkg | expr/expr.go | Visit | func (v *visitor) Visit(node ast.Node) ast.Visitor {
if n, ok := node.(*ast.CallExpr); ok {
if fnIdent, ok := n.Fun.(*ast.Ident); ok {
if _, ok := v.pool.fn(fnIdent.Name); ok {
return v
} else {
v.err = fmt.Errorf("undefined function `%v`", fnIdent.Name)
}
} else {
v.err = fmt.Errorf("unsupport... | go | func (v *visitor) Visit(node ast.Node) ast.Visitor {
if n, ok := node.(*ast.CallExpr); ok {
if fnIdent, ok := n.Fun.(*ast.Ident); ok {
if _, ok := v.pool.fn(fnIdent.Name); ok {
return v
} else {
v.err = fmt.Errorf("undefined function `%v`", fnIdent.Name)
}
} else {
v.err = fmt.Errorf("unsupport... | [
"func",
"(",
"v",
"*",
"visitor",
")",
"Visit",
"(",
"node",
"ast",
".",
"Node",
")",
"ast",
".",
"Visitor",
"{",
"if",
"n",
",",
"ok",
":=",
"node",
".",
"(",
"*",
"ast",
".",
"CallExpr",
")",
";",
"ok",
"{",
"if",
"fnIdent",
",",
"ok",
":="... | // Visit implements ast.Visitor Visit method | [
"Visit",
"implements",
"ast",
".",
"Visitor",
"Visit",
"method"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/expr/expr.go#L77-L91 |
146,462 | mkideal/pkg | expr/expr.go | Eval | func (e *Expr) Eval(getter VarGetter) (Value, error) {
if e.root == nil {
return Zero(), nil
}
v, err := eval(e, getter, e.root)
if err != nil {
return Zero(), err
}
return v, nil
} | go | func (e *Expr) Eval(getter VarGetter) (Value, error) {
if e.root == nil {
return Zero(), nil
}
v, err := eval(e, getter, e.root)
if err != nil {
return Zero(), err
}
return v, nil
} | [
"func",
"(",
"e",
"*",
"Expr",
")",
"Eval",
"(",
"getter",
"VarGetter",
")",
"(",
"Value",
",",
"error",
")",
"{",
"if",
"e",
".",
"root",
"==",
"nil",
"{",
"return",
"Zero",
"(",
")",
",",
"nil",
"\n",
"}",
"\n",
"v",
",",
"err",
":=",
"eval... | // Eval calculate the expression
// getter maybe nil | [
"Eval",
"calculate",
"the",
"expression",
"getter",
"maybe",
"nil"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/expr/expr.go#L95-L104 |
146,463 | mkideal/pkg | textutil/table.go | WriteTable | func WriteTable(w io.Writer, table Table, style TableStyler) {
if style == nil {
style = defaultStyle
}
rowCount, colCount := table.RowCount(), table.ColCount()
if rowCount <= 0 || colCount <= 0 {
return
}
widthArray := make([]int, colCount)
for j := 0; j < colCount; j++ {
maxWidth := 0
for i := 0; i < r... | go | func WriteTable(w io.Writer, table Table, style TableStyler) {
if style == nil {
style = defaultStyle
}
rowCount, colCount := table.RowCount(), table.ColCount()
if rowCount <= 0 || colCount <= 0 {
return
}
widthArray := make([]int, colCount)
for j := 0; j < colCount; j++ {
maxWidth := 0
for i := 0; i < r... | [
"func",
"WriteTable",
"(",
"w",
"io",
".",
"Writer",
",",
"table",
"Table",
",",
"style",
"TableStyler",
")",
"{",
"if",
"style",
"==",
"nil",
"{",
"style",
"=",
"defaultStyle",
"\n",
"}",
"\n",
"rowCount",
",",
"colCount",
":=",
"table",
".",
"RowCoun... | // WriteTable formats table to writer with specified style | [
"WriteTable",
"formats",
"table",
"to",
"writer",
"with",
"specified",
"style"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/textutil/table.go#L70-L99 |
146,464 | mkideal/pkg | textutil/table.go | ClipTable | func ClipTable(table Table, i, j, m, n int) Table {
minR, minC := i, j
maxR, maxC := i+m, j+n
if minR < 0 || minC < 0 || minR > maxR || minC > maxC || maxR >= table.RowCount() || maxC >= table.ColCount() {
panic("out of bound")
}
return &TableView{table, i, j, m, n}
} | go | func ClipTable(table Table, i, j, m, n int) Table {
minR, minC := i, j
maxR, maxC := i+m, j+n
if minR < 0 || minC < 0 || minR > maxR || minC > maxC || maxR >= table.RowCount() || maxC >= table.ColCount() {
panic("out of bound")
}
return &TableView{table, i, j, m, n}
} | [
"func",
"ClipTable",
"(",
"table",
"Table",
",",
"i",
",",
"j",
",",
"m",
",",
"n",
"int",
")",
"Table",
"{",
"minR",
",",
"minC",
":=",
"i",
",",
"j",
"\n",
"maxR",
",",
"maxC",
":=",
"i",
"+",
"m",
",",
"j",
"+",
"n",
"\n",
"if",
"minR",
... | // ClipTable creates a view of table | [
"ClipTable",
"creates",
"a",
"view",
"of",
"table"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/textutil/table.go#L148-L155 |
146,465 | mkideal/pkg | storage/session.go | UpdateByIndexScore | func (s *session) UpdateByIndexScore(table Table, index Index, minScore, maxScore int64, fields ...string) (RangeResult, error) {
action, result, err := s.updateByIndexScore(table, index, minScore, maxScore, fields...)
if err != nil {
action = "UpdateByIndexScore: table=" + table.TableMeta().Name() + ",index=" + in... | go | func (s *session) UpdateByIndexScore(table Table, index Index, minScore, maxScore int64, fields ...string) (RangeResult, error) {
action, result, err := s.updateByIndexScore(table, index, minScore, maxScore, fields...)
if err != nil {
action = "UpdateByIndexScore: table=" + table.TableMeta().Name() + ",index=" + in... | [
"func",
"(",
"s",
"*",
"session",
")",
"UpdateByIndexScore",
"(",
"table",
"Table",
",",
"index",
"Index",
",",
"minScore",
",",
"maxScore",
"int64",
",",
"fields",
"...",
"string",
")",
"(",
"RangeResult",
",",
"error",
")",
"{",
"action",
",",
"result"... | // UpdateByIndexScore updates specific fields of records which satify index score range | [
"UpdateByIndexScore",
"updates",
"specific",
"fields",
"of",
"records",
"which",
"satify",
"index",
"score",
"range"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/session.go#L92-L99 |
146,466 | mkideal/pkg | storage/session.go | Find | func (s *session) Find(keys KeyList, container TableListContainer, opts ...GetOption) error {
action, err := s.find(keys, container, s.applyGetOption(opts), nil)
if err != nil {
return s.catch("Find: "+action, err)
}
return nil
} | go | func (s *session) Find(keys KeyList, container TableListContainer, opts ...GetOption) error {
action, err := s.find(keys, container, s.applyGetOption(opts), nil)
if err != nil {
return s.catch("Find: "+action, err)
}
return nil
} | [
"func",
"(",
"s",
"*",
"session",
")",
"Find",
"(",
"keys",
"KeyList",
",",
"container",
"TableListContainer",
",",
"opts",
"...",
"GetOption",
")",
"error",
"{",
"action",
",",
"err",
":=",
"s",
".",
"find",
"(",
"keys",
",",
"container",
",",
"s",
... | // FindFields gets records all fields by keys and stores loaded data to container | [
"FindFields",
"gets",
"records",
"all",
"fields",
"by",
"keys",
"and",
"stores",
"loaded",
"data",
"to",
"container"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/session.go#L102-L108 |
146,467 | mkideal/pkg | storage/session.go | IndexRangeByLex | func (s *session) IndexRangeByLex(index Index, min, max string, opts ...RangeOption) (RangeLexResult, error) {
action, result, err := s.indexRangeByLex(index, min, max, s.applyRangeOption(opts))
if err != nil {
return nil, s.catch("IndexRangeByLex: "+action, err)
}
return result, nil
} | go | func (s *session) IndexRangeByLex(index Index, min, max string, opts ...RangeOption) (RangeLexResult, error) {
action, result, err := s.indexRangeByLex(index, min, max, s.applyRangeOption(opts))
if err != nil {
return nil, s.catch("IndexRangeByLex: "+action, err)
}
return result, nil
} | [
"func",
"(",
"s",
"*",
"session",
")",
"IndexRangeByLex",
"(",
"index",
"Index",
",",
"min",
",",
"max",
"string",
",",
"opts",
"...",
"RangeOption",
")",
"(",
"RangeLexResult",
",",
"error",
")",
"{",
"action",
",",
"result",
",",
"err",
":=",
"s",
... | // IndexRangeByLex range index by lexicographical order | [
"IndexRangeByLex",
"range",
"index",
"by",
"lexicographical",
"order"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/session.go#L226-L232 |
146,468 | mkideal/pkg | version/version.go | New | func New(app string, major, minor int16, build int64) Version {
return versionImpl{
app: app,
major: major,
minor: minor,
build: build,
}
} | go | func New(app string, major, minor int16, build int64) Version {
return versionImpl{
app: app,
major: major,
minor: minor,
build: build,
}
} | [
"func",
"New",
"(",
"app",
"string",
",",
"major",
",",
"minor",
"int16",
",",
"build",
"int64",
")",
"Version",
"{",
"return",
"versionImpl",
"{",
"app",
":",
"app",
",",
"major",
":",
"major",
",",
"minor",
":",
"minor",
",",
"build",
":",
"build",... | // New creates a version | [
"New",
"creates",
"a",
"version"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/version/version.go#L24-L31 |
146,469 | mkideal/pkg | encoding/cso/cso.go | Read | func Read(r io.Reader) (Node, error) {
s := newScanner()
p := new(parser)
lr := &lineReader{reader: r}
return readLine(p, s, lr)
} | go | func Read(r io.Reader) (Node, error) {
s := newScanner()
p := new(parser)
lr := &lineReader{reader: r}
return readLine(p, s, lr)
} | [
"func",
"Read",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"Node",
",",
"error",
")",
"{",
"s",
":=",
"newScanner",
"(",
")",
"\n",
"p",
":=",
"new",
"(",
"parser",
")",
"\n",
"lr",
":=",
"&",
"lineReader",
"{",
"reader",
":",
"r",
"}",
"\n",
"... | // Read reads one node | [
"Read",
"reads",
"one",
"node"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/cso/cso.go#L78-L83 |
146,470 | mkideal/pkg | encoding/cso/cso.go | ReadAll | func ReadAll(r io.Reader) ([]Node, error) {
s := newScanner()
p := new(parser)
lr := &lineReader{reader: r}
var nodes []Node
for !lr.eof {
lr.reset()
n, err := readLine(p, s, lr)
if err != nil {
return nil, err
}
nodes = append(nodes, n)
}
return nodes, nil
} | go | func ReadAll(r io.Reader) ([]Node, error) {
s := newScanner()
p := new(parser)
lr := &lineReader{reader: r}
var nodes []Node
for !lr.eof {
lr.reset()
n, err := readLine(p, s, lr)
if err != nil {
return nil, err
}
nodes = append(nodes, n)
}
return nodes, nil
} | [
"func",
"ReadAll",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"[",
"]",
"Node",
",",
"error",
")",
"{",
"s",
":=",
"newScanner",
"(",
")",
"\n",
"p",
":=",
"new",
"(",
"parser",
")",
"\n",
"lr",
":=",
"&",
"lineReader",
"{",
"reader",
":",
"r",
... | // ReadAll reads all nodes | [
"ReadAll",
"reads",
"all",
"nodes"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/cso/cso.go#L86-L100 |
146,471 | mkideal/pkg | encoding/cso/cso.go | ReadFile | func ReadFile(filename string) ([]Node, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
return ReadAll(file)
} | go | func ReadFile(filename string) ([]Node, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
return ReadAll(file)
} | [
"func",
"ReadFile",
"(",
"filename",
"string",
")",
"(",
"[",
"]",
"Node",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"... | // ReadFile reads nodes from file | [
"ReadFile",
"reads",
"nodes",
"from",
"file"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/cso/cso.go#L108-L115 |
146,472 | mkideal/pkg | encoding/cso/cso.go | Write | func Write(w io.Writer, node Node) error {
return node.output(w)
} | go | func Write(w io.Writer, node Node) error {
return node.output(w)
} | [
"func",
"Write",
"(",
"w",
"io",
".",
"Writer",
",",
"node",
"Node",
")",
"error",
"{",
"return",
"node",
".",
"output",
"(",
"w",
")",
"\n",
"}"
] | // Write writes node to writer | [
"Write",
"writes",
"node",
"to",
"writer"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/cso/cso.go#L118-L120 |
146,473 | mkideal/pkg | encoding/cso/cso.go | WriteFile | func WriteFile(filename string, node Node, perm os.FileMode) error {
file, err := os.OpenFile(filenname, os.O_CREATE|os.O_WRONLY, perm)
if err == nil {
err = Write(file, node)
}
return err
} | go | func WriteFile(filename string, node Node, perm os.FileMode) error {
file, err := os.OpenFile(filenname, os.O_CREATE|os.O_WRONLY, perm)
if err == nil {
err = Write(file, node)
}
return err
} | [
"func",
"WriteFile",
"(",
"filename",
"string",
",",
"node",
"Node",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"file",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"filenname",
",",
"os",
".",
"O_CREATE",
"|",
"os",
".",
"O_WRONLY",
","... | // WriteFile writes node to file | [
"WriteFile",
"writes",
"node",
"to",
"file"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/encoding/cso/cso.go#L123-L129 |
146,474 | mkideal/pkg | textutil/namemapper/namemapper.go | split | func split(s string) ([]string, bool) {
if s == "" {
return nil, false
}
ret := make([]string, 0)
ccase := 0
const UPPER_CASE = 1
const LOWER_CASE = 2
word := bytes.NewBufferString("")
for i := 0; i < len(s); i++ {
b := s[i]
if b >= 'A' && b <= 'Z' {
if ccase != UPPER_CASE {
if word.Len() > 0 {
... | go | func split(s string) ([]string, bool) {
if s == "" {
return nil, false
}
ret := make([]string, 0)
ccase := 0
const UPPER_CASE = 1
const LOWER_CASE = 2
word := bytes.NewBufferString("")
for i := 0; i < len(s); i++ {
b := s[i]
if b >= 'A' && b <= 'Z' {
if ccase != UPPER_CASE {
if word.Len() > 0 {
... | [
"func",
"split",
"(",
"s",
"string",
")",
"(",
"[",
"]",
"string",
",",
"bool",
")",
"{",
"if",
"s",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\n",
"ret",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"... | // split into slice | [
"split",
"into",
"slice"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/textutil/namemapper/namemapper.go#L147-L186 |
146,475 | mkideal/pkg | optvar/datasource.go | FormString | func FormString(s string) (DataSource, error) {
values, err := url.ParseQuery(s)
if err != nil {
return nil, err
}
return Form(values), nil
} | go | func FormString(s string) (DataSource, error) {
values, err := url.ParseQuery(s)
if err != nil {
return nil, err
}
return Form(values), nil
} | [
"func",
"FormString",
"(",
"s",
"string",
")",
"(",
"DataSource",
",",
"error",
")",
"{",
"values",
",",
"err",
":=",
"url",
".",
"ParseQuery",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ret... | // FormString creates DataSource from raw form string | [
"FormString",
"creates",
"DataSource",
"from",
"raw",
"form",
"string"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/optvar/datasource.go#L72-L78 |
146,476 | mkideal/pkg | optvar/datasource.go | FlagSet | func FlagSet(flagSet *flag.FlagSet) DataSource {
m := map[string]string{}
flagSet.Visit(func(fl *flag.Flag) {
if fl.Value != nil {
m[fl.Name] = fl.Value.String()
}
})
return Map(m)
} | go | func FlagSet(flagSet *flag.FlagSet) DataSource {
m := map[string]string{}
flagSet.Visit(func(fl *flag.Flag) {
if fl.Value != nil {
m[fl.Name] = fl.Value.String()
}
})
return Map(m)
} | [
"func",
"FlagSet",
"(",
"flagSet",
"*",
"flag",
".",
"FlagSet",
")",
"DataSource",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"flagSet",
".",
"Visit",
"(",
"func",
"(",
"fl",
"*",
"flag",
".",
"Flag",
")",
"{",
"if",
"fl... | // FlagSet creates DataSource from flag.FlagSet | [
"FlagSet",
"creates",
"DataSource",
"from",
"flag",
".",
"FlagSet"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/optvar/datasource.go#L93-L101 |
146,477 | mkideal/pkg | container/arraymap/arraymap.go | Get | func (m *ArrayMap) Get(key int) (value T, ok bool) {
if m.isValidKey(key) {
return m.data[key], true
}
return nil, false
} | go | func (m *ArrayMap) Get(key int) (value T, ok bool) {
if m.isValidKey(key) {
return m.data[key], true
}
return nil, false
} | [
"func",
"(",
"m",
"*",
"ArrayMap",
")",
"Get",
"(",
"key",
"int",
")",
"(",
"value",
"T",
",",
"ok",
"bool",
")",
"{",
"if",
"m",
".",
"isValidKey",
"(",
"key",
")",
"{",
"return",
"m",
".",
"data",
"[",
"key",
"]",
",",
"true",
"\n",
"}",
... | // Get gets the value by key | [
"Get",
"gets",
"the",
"value",
"by",
"key"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/container/arraymap/arraymap.go#L39-L44 |
146,478 | mkideal/pkg | container/arraymap/arraymap.go | Add | func (m *ArrayMap) Add(value T) (key int) {
if n := len(m.holes); n > 0 {
key = m.holes[n-1]
m.holes = m.holes[:n-1]
m.data[key] = value
m.validFlags.Set(key, true)
return
}
key = len(m.data)
m.data = append(m.data, value)
m.validFlags.Push(true)
return
} | go | func (m *ArrayMap) Add(value T) (key int) {
if n := len(m.holes); n > 0 {
key = m.holes[n-1]
m.holes = m.holes[:n-1]
m.data[key] = value
m.validFlags.Set(key, true)
return
}
key = len(m.data)
m.data = append(m.data, value)
m.validFlags.Push(true)
return
} | [
"func",
"(",
"m",
"*",
"ArrayMap",
")",
"Add",
"(",
"value",
"T",
")",
"(",
"key",
"int",
")",
"{",
"if",
"n",
":=",
"len",
"(",
"m",
".",
"holes",
")",
";",
"n",
">",
"0",
"{",
"key",
"=",
"m",
".",
"holes",
"[",
"n",
"-",
"1",
"]",
"\... | // Add adds a new element and returns the allocated key | [
"Add",
"adds",
"a",
"new",
"element",
"and",
"returns",
"the",
"allocated",
"key"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/container/arraymap/arraymap.go#L57-L69 |
146,479 | mkideal/pkg | container/arraymap/arraymap.go | Remove | func (m *ArrayMap) Remove(key int) (value T, ok bool) {
if m.isValidKey(key) {
value = m.data[key]
ok = true
m.validFlags.Set(key, false)
m.holes = append(m.holes, key)
}
return
} | go | func (m *ArrayMap) Remove(key int) (value T, ok bool) {
if m.isValidKey(key) {
value = m.data[key]
ok = true
m.validFlags.Set(key, false)
m.holes = append(m.holes, key)
}
return
} | [
"func",
"(",
"m",
"*",
"ArrayMap",
")",
"Remove",
"(",
"key",
"int",
")",
"(",
"value",
"T",
",",
"ok",
"bool",
")",
"{",
"if",
"m",
".",
"isValidKey",
"(",
"key",
")",
"{",
"value",
"=",
"m",
".",
"data",
"[",
"key",
"]",
"\n",
"ok",
"=",
... | // Remove removes the value by key | [
"Remove",
"removes",
"the",
"value",
"by",
"key"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/container/arraymap/arraymap.go#L72-L80 |
146,480 | mkideal/pkg | container/arraymap/arraymap.go | For | func (m *ArrayMap) For(visitor func(key int, value T) (broken bool)) {
for key, value := range m.data {
if m.validFlags.Get(key) {
if visitor(key, value) {
break
}
}
}
} | go | func (m *ArrayMap) For(visitor func(key int, value T) (broken bool)) {
for key, value := range m.data {
if m.validFlags.Get(key) {
if visitor(key, value) {
break
}
}
}
} | [
"func",
"(",
"m",
"*",
"ArrayMap",
")",
"For",
"(",
"visitor",
"func",
"(",
"key",
"int",
",",
"value",
"T",
")",
"(",
"broken",
"bool",
")",
")",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"m",
".",
"data",
"{",
"if",
"m",
".",
"validFlag... | // For traversal the map | [
"For",
"traversal",
"the",
"map"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/container/arraymap/arraymap.go#L83-L91 |
146,481 | mkideal/pkg | debug/stack.go | Stack | func Stack(calldepth int) []byte {
var (
e = make([]byte, 1<<16) // 64k
nbytes = runtime.Stack(e, false)
ignorelinenum = 2*calldepth + 1
count = 0
startIndex = 0
)
for i := range e {
if e[i] == '\n' {
count++
if count == ignorelinenum {
startIndex = i + 1
}
}
... | go | func Stack(calldepth int) []byte {
var (
e = make([]byte, 1<<16) // 64k
nbytes = runtime.Stack(e, false)
ignorelinenum = 2*calldepth + 1
count = 0
startIndex = 0
)
for i := range e {
if e[i] == '\n' {
count++
if count == ignorelinenum {
startIndex = i + 1
}
}
... | [
"func",
"Stack",
"(",
"calldepth",
"int",
")",
"[",
"]",
"byte",
"{",
"var",
"(",
"e",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
"<<",
"16",
")",
"// 64k",
"\n",
"nbytes",
"=",
"runtime",
".",
"Stack",
"(",
"e",
",",
"false",
")",
"\n",
"... | // Stack gets the call stack | [
"Stack",
"gets",
"the",
"call",
"stack"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/debug/stack.go#L8-L25 |
146,482 | mkideal/pkg | flag/validator/validator.go | AndRequire | func (v *ValidatorList) AndRequire(val bool, msg string) *ValidatorList {
(*v) = append((*v), BoolValidator{val: val, msg: msg})
return v
} | go | func (v *ValidatorList) AndRequire(val bool, msg string) *ValidatorList {
(*v) = append((*v), BoolValidator{val: val, msg: msg})
return v
} | [
"func",
"(",
"v",
"*",
"ValidatorList",
")",
"AndRequire",
"(",
"val",
"bool",
",",
"msg",
"string",
")",
"*",
"ValidatorList",
"{",
"(",
"*",
"v",
")",
"=",
"append",
"(",
"(",
"*",
"v",
")",
",",
"BoolValidator",
"{",
"val",
":",
"val",
",",
"m... | // AndRequire appends a boolValidator | [
"AndRequire",
"appends",
"a",
"boolValidator"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/flag/validator/validator.go#L34-L37 |
146,483 | mkideal/pkg | flag/validator/validator.go | And | func (v *ValidatorList) And(validator Validator) *ValidatorList {
(*v) = append((*v), validator)
return v
} | go | func (v *ValidatorList) And(validator Validator) *ValidatorList {
(*v) = append((*v), validator)
return v
} | [
"func",
"(",
"v",
"*",
"ValidatorList",
")",
"And",
"(",
"validator",
"Validator",
")",
"*",
"ValidatorList",
"{",
"(",
"*",
"v",
")",
"=",
"append",
"(",
"(",
"*",
"v",
")",
",",
"validator",
")",
"\n",
"return",
"v",
"\n",
"}"
] | // And appends a Validator | [
"And",
"appends",
"a",
"Validator"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/flag/validator/validator.go#L40-L43 |
146,484 | mkideal/pkg | storage/engine.go | NewEngine | func NewEngine(name string, database DatabaseProxy, cache CacheProxy) Engine {
eng := &engine{
name: name,
database: database,
cache: cache,
indexes: make(map[string]map[string]Index),
}
if eng.cache == nil {
eng.cache = NullCacheProxy
}
return eng
} | go | func NewEngine(name string, database DatabaseProxy, cache CacheProxy) Engine {
eng := &engine{
name: name,
database: database,
cache: cache,
indexes: make(map[string]map[string]Index),
}
if eng.cache == nil {
eng.cache = NullCacheProxy
}
return eng
} | [
"func",
"NewEngine",
"(",
"name",
"string",
",",
"database",
"DatabaseProxy",
",",
"cache",
"CacheProxy",
")",
"Engine",
"{",
"eng",
":=",
"&",
"engine",
"{",
"name",
":",
"name",
",",
"database",
":",
"database",
",",
"cache",
":",
"cache",
",",
"indexe... | // NewEngine creates an engine which named name.
// Parameter database MUST be not nil, but cache can be nil. | [
"NewEngine",
"creates",
"an",
"engine",
"which",
"named",
"name",
".",
"Parameter",
"database",
"MUST",
"be",
"not",
"nil",
"but",
"cache",
"can",
"be",
"nil",
"."
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/engine.go#L31-L42 |
146,485 | mkideal/pkg | storage/engine.go | AddIndex | func (eng *engine) AddIndex(index Index) {
tableName := index.TableMeta().Name()
idx, ok := eng.indexes[tableName]
if !ok {
idx = make(map[string]Index)
eng.indexes[tableName] = idx
}
indexName := index.Name()
if _, exist := idx[indexName]; exist {
panic("index " + indexName + " existed on table " + tableNa... | go | func (eng *engine) AddIndex(index Index) {
tableName := index.TableMeta().Name()
idx, ok := eng.indexes[tableName]
if !ok {
idx = make(map[string]Index)
eng.indexes[tableName] = idx
}
indexName := index.Name()
if _, exist := idx[indexName]; exist {
panic("index " + indexName + " existed on table " + tableNa... | [
"func",
"(",
"eng",
"*",
"engine",
")",
"AddIndex",
"(",
"index",
"Index",
")",
"{",
"tableName",
":=",
"index",
".",
"TableMeta",
"(",
")",
".",
"Name",
"(",
")",
"\n",
"idx",
",",
"ok",
":=",
"eng",
".",
"indexes",
"[",
"tableName",
"]",
"\n",
... | // AddIndex adds an index
// panic if repeated index name on a same table | [
"AddIndex",
"adds",
"an",
"index",
"panic",
"if",
"repeated",
"index",
"name",
"on",
"a",
"same",
"table"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/engine.go#L55-L67 |
146,486 | mkideal/pkg | storage/engine.go | Find | func (eng *engine) Find(keys KeyList, container TableListContainer, opts ...GetOption) error {
s := eng.newSession()
defer s.Close()
action, err := s.find(keys, container, s.applyGetOption(opts), nil)
if err != nil {
return s.catch("Find: "+action, err)
}
return nil
} | go | func (eng *engine) Find(keys KeyList, container TableListContainer, opts ...GetOption) error {
s := eng.newSession()
defer s.Close()
action, err := s.find(keys, container, s.applyGetOption(opts), nil)
if err != nil {
return s.catch("Find: "+action, err)
}
return nil
} | [
"func",
"(",
"eng",
"*",
"engine",
")",
"Find",
"(",
"keys",
"KeyList",
",",
"container",
"TableListContainer",
",",
"opts",
"...",
"GetOption",
")",
"error",
"{",
"s",
":=",
"eng",
".",
"newSession",
"(",
")",
"\n",
"defer",
"s",
".",
"Close",
"(",
... | // Find gets records all fields by keys and stores loaded data to container | [
"Find",
"gets",
"records",
"all",
"fields",
"by",
"keys",
"and",
"stores",
"loaded",
"data",
"to",
"container"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/engine.go#L121-L129 |
146,487 | mkideal/pkg | storage/engine.go | IndexRangeByLex | func (eng *engine) IndexRangeByLex(index Index, min, max string, opts ...RangeOption) (RangeLexResult, error) {
s := eng.newSession()
defer s.Close()
action, result, err := s.indexRangeByLex(index, min, max, s.applyRangeOption(opts))
if err != nil {
return nil, s.catch("IndexRangeByLex: "+action, err)
}
return ... | go | func (eng *engine) IndexRangeByLex(index Index, min, max string, opts ...RangeOption) (RangeLexResult, error) {
s := eng.newSession()
defer s.Close()
action, result, err := s.indexRangeByLex(index, min, max, s.applyRangeOption(opts))
if err != nil {
return nil, s.catch("IndexRangeByLex: "+action, err)
}
return ... | [
"func",
"(",
"eng",
"*",
"engine",
")",
"IndexRangeByLex",
"(",
"index",
"Index",
",",
"min",
",",
"max",
"string",
",",
"opts",
"...",
"RangeOption",
")",
"(",
"RangeLexResult",
",",
"error",
")",
"{",
"s",
":=",
"eng",
".",
"newSession",
"(",
")",
... | // IndexRangeByLex range index by lexicographical | [
"IndexRangeByLex",
"range",
"index",
"by",
"lexicographical"
] | 3e188c9e7ecc83d0fe7040a9161ce3c67885470d | https://github.com/mkideal/pkg/blob/3e188c9e7ecc83d0fe7040a9161ce3c67885470d/storage/engine.go#L273-L281 |
146,488 | mailgun/multibuf | buffer.go | MaxBytes | func MaxBytes(m int64) optionSetter {
return func(o *options) error {
o.maxBytes = m
return nil
}
} | go | func MaxBytes(m int64) optionSetter {
return func(o *options) error {
o.maxBytes = m
return nil
}
} | [
"func",
"MaxBytes",
"(",
"m",
"int64",
")",
"optionSetter",
"{",
"return",
"func",
"(",
"o",
"*",
"options",
")",
"error",
"{",
"o",
".",
"maxBytes",
"=",
"m",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // MaxBytes, ignored if set to value >=, if request exceeds the specified limit, the reader will return error,
// by default buffer is not limited, negative values mean no limit | [
"MaxBytes",
"ignored",
"if",
"set",
"to",
"value",
">",
"=",
"if",
"request",
"exceeds",
"the",
"specified",
"limit",
"the",
"reader",
"will",
"return",
"error",
"by",
"default",
"buffer",
"is",
"not",
"limited",
"negative",
"values",
"mean",
"no",
"limit"
] | 565402cd71fbd9c12aa7e295324ea357e970a61e | https://github.com/mailgun/multibuf/blob/565402cd71fbd9c12aa7e295324ea357e970a61e/buffer.go#L38-L43 |
146,489 | mailgun/multibuf | buffer.go | MemBytes | func MemBytes(m int64) optionSetter {
return func(o *options) error {
if m < 0 {
return fmt.Errorf("MemBytes should be >= 0")
}
o.memBytes = m
return nil
}
} | go | func MemBytes(m int64) optionSetter {
return func(o *options) error {
if m < 0 {
return fmt.Errorf("MemBytes should be >= 0")
}
o.memBytes = m
return nil
}
} | [
"func",
"MemBytes",
"(",
"m",
"int64",
")",
"optionSetter",
"{",
"return",
"func",
"(",
"o",
"*",
"options",
")",
"error",
"{",
"if",
"m",
"<",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"o",
".",
"memBytes",... | // MemBytes specifies the largest buffer to hold in RAM before writing to disk, default is 1MB | [
"MemBytes",
"specifies",
"the",
"largest",
"buffer",
"to",
"hold",
"in",
"RAM",
"before",
"writing",
"to",
"disk",
"default",
"is",
"1MB"
] | 565402cd71fbd9c12aa7e295324ea357e970a61e | https://github.com/mailgun/multibuf/blob/565402cd71fbd9c12aa7e295324ea357e970a61e/buffer.go#L46-L54 |
146,490 | mailgun/multibuf | buffer.go | writeToMem | func (w *writerOnce) writeToMem(p []byte) int {
left := w.o.memBytes - w.total
if left <= 0 {
return 0
}
bufLen := len(p)
if int64(bufLen) < left {
return bufLen
}
return int(left)
} | go | func (w *writerOnce) writeToMem(p []byte) int {
left := w.o.memBytes - w.total
if left <= 0 {
return 0
}
bufLen := len(p)
if int64(bufLen) < left {
return bufLen
}
return int(left)
} | [
"func",
"(",
"w",
"*",
"writerOnce",
")",
"writeToMem",
"(",
"p",
"[",
"]",
"byte",
")",
"int",
"{",
"left",
":=",
"w",
".",
"o",
".",
"memBytes",
"-",
"w",
".",
"total",
"\n",
"if",
"left",
"<=",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"bu... | // how many bytes we can still write to memory | [
"how",
"many",
"bytes",
"we",
"can",
"still",
"write",
"to",
"memory"
] | 565402cd71fbd9c12aa7e295324ea357e970a61e | https://github.com/mailgun/multibuf/blob/565402cd71fbd9c12aa7e295324ea357e970a61e/buffer.go#L310-L320 |
146,491 | nuagenetworks/vspk-go | vspk/ingressacltemplate.go | IngressACLEntryTemplates | func (o *IngressACLTemplate) IngressACLEntryTemplates(info *bambou.FetchingInfo) (IngressACLEntryTemplatesList, *bambou.Error) {
var list IngressACLEntryTemplatesList
err := bambou.CurrentSession().FetchChildren(o, IngressACLEntryTemplateIdentity, &list, info)
return list, err
} | go | func (o *IngressACLTemplate) IngressACLEntryTemplates(info *bambou.FetchingInfo) (IngressACLEntryTemplatesList, *bambou.Error) {
var list IngressACLEntryTemplatesList
err := bambou.CurrentSession().FetchChildren(o, IngressACLEntryTemplateIdentity, &list, info)
return list, err
} | [
"func",
"(",
"o",
"*",
"IngressACLTemplate",
")",
"IngressACLEntryTemplates",
"(",
"info",
"*",
"bambou",
".",
"FetchingInfo",
")",
"(",
"IngressACLEntryTemplatesList",
",",
"*",
"bambou",
".",
"Error",
")",
"{",
"var",
"list",
"IngressACLEntryTemplatesList",
"\n"... | // IngressACLEntryTemplates retrieves the list of child IngressACLEntryTemplates of the IngressACLTemplate | [
"IngressACLEntryTemplates",
"retrieves",
"the",
"list",
"of",
"child",
"IngressACLEntryTemplates",
"of",
"the",
"IngressACLTemplate"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/ingressacltemplate.go#L158-L163 |
146,492 | nuagenetworks/vspk-go | vspk/ingressacltemplate.go | CreateIngressACLEntryTemplate | func (o *IngressACLTemplate) CreateIngressACLEntryTemplate(child *IngressACLEntryTemplate) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | go | func (o *IngressACLTemplate) CreateIngressACLEntryTemplate(child *IngressACLEntryTemplate) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | [
"func",
"(",
"o",
"*",
"IngressACLTemplate",
")",
"CreateIngressACLEntryTemplate",
"(",
"child",
"*",
"IngressACLEntryTemplate",
")",
"*",
"bambou",
".",
"Error",
"{",
"return",
"bambou",
".",
"CurrentSession",
"(",
")",
".",
"CreateChild",
"(",
"o",
",",
"chi... | // CreateIngressACLEntryTemplate creates a new child IngressACLEntryTemplate under the IngressACLTemplate | [
"CreateIngressACLEntryTemplate",
"creates",
"a",
"new",
"child",
"IngressACLEntryTemplate",
"under",
"the",
"IngressACLTemplate"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/ingressacltemplate.go#L166-L169 |
146,493 | nuagenetworks/vspk-go | vspk/keyservermonitor.go | KeyServerMonitorEncryptedSeeds | func (o *KeyServerMonitor) KeyServerMonitorEncryptedSeeds(info *bambou.FetchingInfo) (KeyServerMonitorEncryptedSeedsList, *bambou.Error) {
var list KeyServerMonitorEncryptedSeedsList
err := bambou.CurrentSession().FetchChildren(o, KeyServerMonitorEncryptedSeedIdentity, &list, info)
return list, err
} | go | func (o *KeyServerMonitor) KeyServerMonitorEncryptedSeeds(info *bambou.FetchingInfo) (KeyServerMonitorEncryptedSeedsList, *bambou.Error) {
var list KeyServerMonitorEncryptedSeedsList
err := bambou.CurrentSession().FetchChildren(o, KeyServerMonitorEncryptedSeedIdentity, &list, info)
return list, err
} | [
"func",
"(",
"o",
"*",
"KeyServerMonitor",
")",
"KeyServerMonitorEncryptedSeeds",
"(",
"info",
"*",
"bambou",
".",
"FetchingInfo",
")",
"(",
"KeyServerMonitorEncryptedSeedsList",
",",
"*",
"bambou",
".",
"Error",
")",
"{",
"var",
"list",
"KeyServerMonitorEncryptedSe... | // KeyServerMonitorEncryptedSeeds retrieves the list of child KeyServerMonitorEncryptedSeeds of the KeyServerMonitor | [
"KeyServerMonitorEncryptedSeeds",
"retrieves",
"the",
"list",
"of",
"child",
"KeyServerMonitorEncryptedSeeds",
"of",
"the",
"KeyServerMonitor"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/keyservermonitor.go#L131-L136 |
146,494 | nuagenetworks/vspk-go | vspk/keyservermonitor.go | CreateKeyServerMonitorEncryptedSeed | func (o *KeyServerMonitor) CreateKeyServerMonitorEncryptedSeed(child *KeyServerMonitorEncryptedSeed) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | go | func (o *KeyServerMonitor) CreateKeyServerMonitorEncryptedSeed(child *KeyServerMonitorEncryptedSeed) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | [
"func",
"(",
"o",
"*",
"KeyServerMonitor",
")",
"CreateKeyServerMonitorEncryptedSeed",
"(",
"child",
"*",
"KeyServerMonitorEncryptedSeed",
")",
"*",
"bambou",
".",
"Error",
"{",
"return",
"bambou",
".",
"CurrentSession",
"(",
")",
".",
"CreateChild",
"(",
"o",
"... | // CreateKeyServerMonitorEncryptedSeed creates a new child KeyServerMonitorEncryptedSeed under the KeyServerMonitor | [
"CreateKeyServerMonitorEncryptedSeed",
"creates",
"a",
"new",
"child",
"KeyServerMonitorEncryptedSeed",
"under",
"the",
"KeyServerMonitor"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/keyservermonitor.go#L139-L142 |
146,495 | nuagenetworks/vspk-go | vspk/keyservermonitor.go | KeyServerMonitorSeeds | func (o *KeyServerMonitor) KeyServerMonitorSeeds(info *bambou.FetchingInfo) (KeyServerMonitorSeedsList, *bambou.Error) {
var list KeyServerMonitorSeedsList
err := bambou.CurrentSession().FetchChildren(o, KeyServerMonitorSeedIdentity, &list, info)
return list, err
} | go | func (o *KeyServerMonitor) KeyServerMonitorSeeds(info *bambou.FetchingInfo) (KeyServerMonitorSeedsList, *bambou.Error) {
var list KeyServerMonitorSeedsList
err := bambou.CurrentSession().FetchChildren(o, KeyServerMonitorSeedIdentity, &list, info)
return list, err
} | [
"func",
"(",
"o",
"*",
"KeyServerMonitor",
")",
"KeyServerMonitorSeeds",
"(",
"info",
"*",
"bambou",
".",
"FetchingInfo",
")",
"(",
"KeyServerMonitorSeedsList",
",",
"*",
"bambou",
".",
"Error",
")",
"{",
"var",
"list",
"KeyServerMonitorSeedsList",
"\n",
"err",
... | // KeyServerMonitorSeeds retrieves the list of child KeyServerMonitorSeeds of the KeyServerMonitor | [
"KeyServerMonitorSeeds",
"retrieves",
"the",
"list",
"of",
"child",
"KeyServerMonitorSeeds",
"of",
"the",
"KeyServerMonitor"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/keyservermonitor.go#L145-L150 |
146,496 | nuagenetworks/vspk-go | vspk/keyservermonitor.go | CreateKeyServerMonitorSeed | func (o *KeyServerMonitor) CreateKeyServerMonitorSeed(child *KeyServerMonitorSeed) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | go | func (o *KeyServerMonitor) CreateKeyServerMonitorSeed(child *KeyServerMonitorSeed) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | [
"func",
"(",
"o",
"*",
"KeyServerMonitor",
")",
"CreateKeyServerMonitorSeed",
"(",
"child",
"*",
"KeyServerMonitorSeed",
")",
"*",
"bambou",
".",
"Error",
"{",
"return",
"bambou",
".",
"CurrentSession",
"(",
")",
".",
"CreateChild",
"(",
"o",
",",
"child",
"... | // CreateKeyServerMonitorSeed creates a new child KeyServerMonitorSeed under the KeyServerMonitor | [
"CreateKeyServerMonitorSeed",
"creates",
"a",
"new",
"child",
"KeyServerMonitorSeed",
"under",
"the",
"KeyServerMonitor"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/keyservermonitor.go#L153-L156 |
146,497 | nuagenetworks/vspk-go | vspk/keyservermonitor.go | KeyServerMonitorSEKs | func (o *KeyServerMonitor) KeyServerMonitorSEKs(info *bambou.FetchingInfo) (KeyServerMonitorSEKsList, *bambou.Error) {
var list KeyServerMonitorSEKsList
err := bambou.CurrentSession().FetchChildren(o, KeyServerMonitorSEKIdentity, &list, info)
return list, err
} | go | func (o *KeyServerMonitor) KeyServerMonitorSEKs(info *bambou.FetchingInfo) (KeyServerMonitorSEKsList, *bambou.Error) {
var list KeyServerMonitorSEKsList
err := bambou.CurrentSession().FetchChildren(o, KeyServerMonitorSEKIdentity, &list, info)
return list, err
} | [
"func",
"(",
"o",
"*",
"KeyServerMonitor",
")",
"KeyServerMonitorSEKs",
"(",
"info",
"*",
"bambou",
".",
"FetchingInfo",
")",
"(",
"KeyServerMonitorSEKsList",
",",
"*",
"bambou",
".",
"Error",
")",
"{",
"var",
"list",
"KeyServerMonitorSEKsList",
"\n",
"err",
"... | // KeyServerMonitorSEKs retrieves the list of child KeyServerMonitorSEKs of the KeyServerMonitor | [
"KeyServerMonitorSEKs",
"retrieves",
"the",
"list",
"of",
"child",
"KeyServerMonitorSEKs",
"of",
"the",
"KeyServerMonitor"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/keyservermonitor.go#L159-L164 |
146,498 | nuagenetworks/vspk-go | vspk/keyservermonitor.go | CreateKeyServerMonitorSEK | func (o *KeyServerMonitor) CreateKeyServerMonitorSEK(child *KeyServerMonitorSEK) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | go | func (o *KeyServerMonitor) CreateKeyServerMonitorSEK(child *KeyServerMonitorSEK) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | [
"func",
"(",
"o",
"*",
"KeyServerMonitor",
")",
"CreateKeyServerMonitorSEK",
"(",
"child",
"*",
"KeyServerMonitorSEK",
")",
"*",
"bambou",
".",
"Error",
"{",
"return",
"bambou",
".",
"CurrentSession",
"(",
")",
".",
"CreateChild",
"(",
"o",
",",
"child",
")"... | // CreateKeyServerMonitorSEK creates a new child KeyServerMonitorSEK under the KeyServerMonitor | [
"CreateKeyServerMonitorSEK",
"creates",
"a",
"new",
"child",
"KeyServerMonitorSEK",
"under",
"the",
"KeyServerMonitor"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/keyservermonitor.go#L167-L170 |
146,499 | nuagenetworks/vspk-go | vspk/applicationperformancemanagement.go | CreateApplicationBinding | func (o *Applicationperformancemanagement) CreateApplicationBinding(child *ApplicationBinding) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | go | func (o *Applicationperformancemanagement) CreateApplicationBinding(child *ApplicationBinding) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
} | [
"func",
"(",
"o",
"*",
"Applicationperformancemanagement",
")",
"CreateApplicationBinding",
"(",
"child",
"*",
"ApplicationBinding",
")",
"*",
"bambou",
".",
"Error",
"{",
"return",
"bambou",
".",
"CurrentSession",
"(",
")",
".",
"CreateChild",
"(",
"o",
",",
... | // CreateApplicationBinding creates a new child ApplicationBinding under the Applicationperformancemanagement | [
"CreateApplicationBinding",
"creates",
"a",
"new",
"child",
"ApplicationBinding",
"under",
"the",
"Applicationperformancemanagement"
] | c241b25534a9c311aaf7b2e180ad664a4085f935 | https://github.com/nuagenetworks/vspk-go/blob/c241b25534a9c311aaf7b2e180ad664a4085f935/vspk/applicationperformancemanagement.go#L153-L156 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.