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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
rs/zerolog | context.go | AnErr | func (c Context) AnErr(key string, err error) Context {
marshaled := ErrorMarshalFunc(err)
switch m := marshaled.(type) {
case nil:
return c
case LogObjectMarshaler:
return c.Object(key, m)
case error:
return c.Str(key, m.Error())
case string:
return c.Str(key, m)
default:
return c.Interface(key, m)
}
} | go | func (c Context) AnErr(key string, err error) Context {
marshaled := ErrorMarshalFunc(err)
switch m := marshaled.(type) {
case nil:
return c
case LogObjectMarshaler:
return c.Object(key, m)
case error:
return c.Str(key, m.Error())
case string:
return c.Str(key, m)
default:
return c.Interface(key, m)
}
} | [
"func",
"(",
"c",
"Context",
")",
"AnErr",
"(",
"key",
"string",
",",
"err",
"error",
")",
"Context",
"{",
"marshaled",
":=",
"ErrorMarshalFunc",
"(",
"err",
")",
"\n",
"switch",
"m",
":=",
"marshaled",
".",
"(",
"type",
")",
"{",
"case",
"nil",
":",... | // AnErr adds the field key with serialized err to the logger context. | [
"AnErr",
"adds",
"the",
"field",
"key",
"with",
"serialized",
"err",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L106-L120 | train |
rs/zerolog | context.go | Errs | func (c Context) Errs(key string, errs []error) Context {
arr := Arr()
for _, err := range errs {
marshaled := ErrorMarshalFunc(err)
switch m := marshaled.(type) {
case LogObjectMarshaler:
arr = arr.Object(m)
case error:
arr = arr.Str(m.Error())
case string:
arr = arr.Str(m)
default:
arr = arr.Interface(m)
}
}
return c.Array(key, arr)
} | go | func (c Context) Errs(key string, errs []error) Context {
arr := Arr()
for _, err := range errs {
marshaled := ErrorMarshalFunc(err)
switch m := marshaled.(type) {
case LogObjectMarshaler:
arr = arr.Object(m)
case error:
arr = arr.Str(m.Error())
case string:
arr = arr.Str(m)
default:
arr = arr.Interface(m)
}
}
return c.Array(key, arr)
} | [
"func",
"(",
"c",
"Context",
")",
"Errs",
"(",
"key",
"string",
",",
"errs",
"[",
"]",
"error",
")",
"Context",
"{",
"arr",
":=",
"Arr",
"(",
")",
"\n",
"for",
"_",
",",
"err",
":=",
"range",
"errs",
"{",
"marshaled",
":=",
"ErrorMarshalFunc",
"(",... | // Errs adds the field key with errs as an array of serialized errors to the
// logger context. | [
"Errs",
"adds",
"the",
"field",
"key",
"with",
"errs",
"as",
"an",
"array",
"of",
"serialized",
"errors",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L124-L141 | train |
rs/zerolog | context.go | Err | func (c Context) Err(err error) Context {
return c.AnErr(ErrorFieldName, err)
} | go | func (c Context) Err(err error) Context {
return c.AnErr(ErrorFieldName, err)
} | [
"func",
"(",
"c",
"Context",
")",
"Err",
"(",
"err",
"error",
")",
"Context",
"{",
"return",
"c",
".",
"AnErr",
"(",
"ErrorFieldName",
",",
"err",
")",
"\n",
"}"
] | // Err adds the field "error" with serialized err to the logger context. | [
"Err",
"adds",
"the",
"field",
"error",
"with",
"serialized",
"err",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L144-L146 | train |
rs/zerolog | context.go | Bool | func (c Context) Bool(key string, b bool) Context {
c.l.context = enc.AppendBool(enc.AppendKey(c.l.context, key), b)
return c
} | go | func (c Context) Bool(key string, b bool) Context {
c.l.context = enc.AppendBool(enc.AppendKey(c.l.context, key), b)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Bool",
"(",
"key",
"string",
",",
"b",
"bool",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendBool",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
"... | // Bool adds the field key with val as a bool to the logger context. | [
"Bool",
"adds",
"the",
"field",
"key",
"with",
"val",
"as",
"a",
"bool",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L149-L152 | train |
rs/zerolog | context.go | Int | func (c Context) Int(key string, i int) Context {
c.l.context = enc.AppendInt(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Int(key string, i int) Context {
c.l.context = enc.AppendInt(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Int",
"(",
"key",
"string",
",",
"i",
"int",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendInt",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
")",... | // Int adds the field key with i as a int to the logger context. | [
"Int",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"int",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L161-L164 | train |
rs/zerolog | context.go | Int8 | func (c Context) Int8(key string, i int8) Context {
c.l.context = enc.AppendInt8(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Int8(key string, i int8) Context {
c.l.context = enc.AppendInt8(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Int8",
"(",
"key",
"string",
",",
"i",
"int8",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendInt8",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
"... | // Int8 adds the field key with i as a int8 to the logger context. | [
"Int8",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"int8",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L173-L176 | train |
rs/zerolog | context.go | Int16 | func (c Context) Int16(key string, i int16) Context {
c.l.context = enc.AppendInt16(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Int16(key string, i int16) Context {
c.l.context = enc.AppendInt16(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Int16",
"(",
"key",
"string",
",",
"i",
"int16",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendInt16",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
... | // Int16 adds the field key with i as a int16 to the logger context. | [
"Int16",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"int16",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L185-L188 | train |
rs/zerolog | context.go | Int32 | func (c Context) Int32(key string, i int32) Context {
c.l.context = enc.AppendInt32(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Int32(key string, i int32) Context {
c.l.context = enc.AppendInt32(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Int32",
"(",
"key",
"string",
",",
"i",
"int32",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendInt32",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
... | // Int32 adds the field key with i as a int32 to the logger context. | [
"Int32",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"int32",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L197-L200 | train |
rs/zerolog | context.go | Int64 | func (c Context) Int64(key string, i int64) Context {
c.l.context = enc.AppendInt64(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Int64(key string, i int64) Context {
c.l.context = enc.AppendInt64(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Int64",
"(",
"key",
"string",
",",
"i",
"int64",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendInt64",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
... | // Int64 adds the field key with i as a int64 to the logger context. | [
"Int64",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"int64",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L209-L212 | train |
rs/zerolog | context.go | Uint | func (c Context) Uint(key string, i uint) Context {
c.l.context = enc.AppendUint(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Uint(key string, i uint) Context {
c.l.context = enc.AppendUint(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Uint",
"(",
"key",
"string",
",",
"i",
"uint",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendUint",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
"... | // Uint adds the field key with i as a uint to the logger context. | [
"Uint",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"uint",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L221-L224 | train |
rs/zerolog | context.go | Uint8 | func (c Context) Uint8(key string, i uint8) Context {
c.l.context = enc.AppendUint8(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Uint8(key string, i uint8) Context {
c.l.context = enc.AppendUint8(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Uint8",
"(",
"key",
"string",
",",
"i",
"uint8",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendUint8",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key",
... | // Uint8 adds the field key with i as a uint8 to the logger context. | [
"Uint8",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"uint8",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L233-L236 | train |
rs/zerolog | context.go | Uint16 | func (c Context) Uint16(key string, i uint16) Context {
c.l.context = enc.AppendUint16(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Uint16(key string, i uint16) Context {
c.l.context = enc.AppendUint16(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Uint16",
"(",
"key",
"string",
",",
"i",
"uint16",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendUint16",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key... | // Uint16 adds the field key with i as a uint16 to the logger context. | [
"Uint16",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"uint16",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L245-L248 | train |
rs/zerolog | context.go | Uint32 | func (c Context) Uint32(key string, i uint32) Context {
c.l.context = enc.AppendUint32(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Uint32(key string, i uint32) Context {
c.l.context = enc.AppendUint32(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Uint32",
"(",
"key",
"string",
",",
"i",
"uint32",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendUint32",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key... | // Uint32 adds the field key with i as a uint32 to the logger context. | [
"Uint32",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"uint32",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L257-L260 | train |
rs/zerolog | context.go | Uint64 | func (c Context) Uint64(key string, i uint64) Context {
c.l.context = enc.AppendUint64(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Uint64(key string, i uint64) Context {
c.l.context = enc.AppendUint64(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Uint64",
"(",
"key",
"string",
",",
"i",
"uint64",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendUint64",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"key... | // Uint64 adds the field key with i as a uint64 to the logger context. | [
"Uint64",
"adds",
"the",
"field",
"key",
"with",
"i",
"as",
"a",
"uint64",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L269-L272 | train |
rs/zerolog | context.go | Float32 | func (c Context) Float32(key string, f float32) Context {
c.l.context = enc.AppendFloat32(enc.AppendKey(c.l.context, key), f)
return c
} | go | func (c Context) Float32(key string, f float32) Context {
c.l.context = enc.AppendFloat32(enc.AppendKey(c.l.context, key), f)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Float32",
"(",
"key",
"string",
",",
"f",
"float32",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendFloat32",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"... | // Float32 adds the field key with f as a float32 to the logger context. | [
"Float32",
"adds",
"the",
"field",
"key",
"with",
"f",
"as",
"a",
"float32",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L281-L284 | train |
rs/zerolog | context.go | Float64 | func (c Context) Float64(key string, f float64) Context {
c.l.context = enc.AppendFloat64(enc.AppendKey(c.l.context, key), f)
return c
} | go | func (c Context) Float64(key string, f float64) Context {
c.l.context = enc.AppendFloat64(enc.AppendKey(c.l.context, key), f)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Float64",
"(",
"key",
"string",
",",
"f",
"float64",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendFloat64",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
",",
"... | // Float64 adds the field key with f as a float64 to the logger context. | [
"Float64",
"adds",
"the",
"field",
"key",
"with",
"f",
"as",
"a",
"float64",
"to",
"the",
"logger",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L293-L296 | train |
rs/zerolog | context.go | Dur | func (c Context) Dur(key string, d time.Duration) Context {
c.l.context = enc.AppendDuration(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger)
return c
} | go | func (c Context) Dur(key string, d time.Duration) Context {
c.l.context = enc.AppendDuration(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Dur",
"(",
"key",
"string",
",",
"d",
"time",
".",
"Duration",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendDuration",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"conte... | // Dur adds the fields key with d divided by unit and stored as a float. | [
"Dur",
"adds",
"the",
"fields",
"key",
"with",
"d",
"divided",
"by",
"unit",
"and",
"stored",
"as",
"a",
"float",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L334-L337 | train |
rs/zerolog | context.go | Durs | func (c Context) Durs(key string, d []time.Duration) Context {
c.l.context = enc.AppendDurations(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger)
return c
} | go | func (c Context) Durs(key string, d []time.Duration) Context {
c.l.context = enc.AppendDurations(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Durs",
"(",
"key",
"string",
",",
"d",
"[",
"]",
"time",
".",
"Duration",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendDurations",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",... | // Durs adds the fields key with d divided by unit and stored as a float. | [
"Durs",
"adds",
"the",
"fields",
"key",
"with",
"d",
"divided",
"by",
"unit",
"and",
"stored",
"as",
"a",
"float",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L340-L343 | train |
rs/zerolog | context.go | Interface | func (c Context) Interface(key string, i interface{}) Context {
c.l.context = enc.AppendInterface(enc.AppendKey(c.l.context, key), i)
return c
} | go | func (c Context) Interface(key string, i interface{}) Context {
c.l.context = enc.AppendInterface(enc.AppendKey(c.l.context, key), i)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"Interface",
"(",
"key",
"string",
",",
"i",
"interface",
"{",
"}",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendInterface",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"... | // Interface adds the field key with obj marshaled using reflection. | [
"Interface",
"adds",
"the",
"field",
"key",
"with",
"obj",
"marshaled",
"using",
"reflection",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L346-L349 | train |
rs/zerolog | context.go | IPAddr | func (c Context) IPAddr(key string, ip net.IP) Context {
c.l.context = enc.AppendIPAddr(enc.AppendKey(c.l.context, key), ip)
return c
} | go | func (c Context) IPAddr(key string, ip net.IP) Context {
c.l.context = enc.AppendIPAddr(enc.AppendKey(c.l.context, key), ip)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"IPAddr",
"(",
"key",
"string",
",",
"ip",
"net",
".",
"IP",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendIPAddr",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
"context",
... | // IPAddr adds IPv4 or IPv6 Address to the context | [
"IPAddr",
"adds",
"IPv4",
"or",
"IPv6",
"Address",
"to",
"the",
"context"
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L406-L409 | train |
rs/zerolog | context.go | MACAddr | func (c Context) MACAddr(key string, ha net.HardwareAddr) Context {
c.l.context = enc.AppendMACAddr(enc.AppendKey(c.l.context, key), ha)
return c
} | go | func (c Context) MACAddr(key string, ha net.HardwareAddr) Context {
c.l.context = enc.AppendMACAddr(enc.AppendKey(c.l.context, key), ha)
return c
} | [
"func",
"(",
"c",
"Context",
")",
"MACAddr",
"(",
"key",
"string",
",",
"ha",
"net",
".",
"HardwareAddr",
")",
"Context",
"{",
"c",
".",
"l",
".",
"context",
"=",
"enc",
".",
"AppendMACAddr",
"(",
"enc",
".",
"AppendKey",
"(",
"c",
".",
"l",
".",
... | // MACAddr adds MAC address to the context | [
"MACAddr",
"adds",
"MAC",
"address",
"to",
"the",
"context"
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/context.go#L418-L421 | train |
rs/zerolog | globals.go | DisableSampling | func DisableSampling(v bool) {
var i uint32
if v {
i = 1
}
atomic.StoreUint32(disableSampling, i)
} | go | func DisableSampling(v bool) {
var i uint32
if v {
i = 1
}
atomic.StoreUint32(disableSampling, i)
} | [
"func",
"DisableSampling",
"(",
"v",
"bool",
")",
"{",
"var",
"i",
"uint32",
"\n",
"if",
"v",
"{",
"i",
"=",
"1",
"\n",
"}",
"\n",
"atomic",
".",
"StoreUint32",
"(",
"disableSampling",
",",
"i",
")",
"\n",
"}"
] | // DisableSampling will disable sampling in all Loggers if true. | [
"DisableSampling",
"will",
"disable",
"sampling",
"in",
"all",
"Loggers",
"if",
"true",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/globals.go#L100-L106 | train |
rs/zerolog | event.go | RawJSON | func (e *Event) RawJSON(key string, b []byte) *Event {
if e == nil {
return e
}
e.buf = appendJSON(enc.AppendKey(e.buf, key), b)
return e
} | go | func (e *Event) RawJSON(key string, b []byte) *Event {
if e == nil {
return e
}
e.buf = appendJSON(enc.AppendKey(e.buf, key), b)
return e
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"RawJSON",
"(",
"key",
"string",
",",
"b",
"[",
"]",
"byte",
")",
"*",
"Event",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n",
"e",
".",
"buf",
"=",
"appendJSON",
"(",
"enc",
".",
"Appen... | // RawJSON adds already encoded JSON to the log line under key.
//
// No sanity check is performed on b; it must not contain carriage returns and
// be valid JSON. | [
"RawJSON",
"adds",
"already",
"encoded",
"JSON",
"to",
"the",
"log",
"line",
"under",
"key",
".",
"No",
"sanity",
"check",
"is",
"performed",
"on",
"b",
";",
"it",
"must",
"not",
"contain",
"carriage",
"returns",
"and",
"be",
"valid",
"JSON",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/event.go#L258-L264 | train |
rs/zerolog | event.go | Dur | func (e *Event) Dur(key string, d time.Duration) *Event {
if e == nil {
return e
}
e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger)
return e
} | go | func (e *Event) Dur(key string, d time.Duration) *Event {
if e == nil {
return e
}
e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger)
return e
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"Dur",
"(",
"key",
"string",
",",
"d",
"time",
".",
"Duration",
")",
"*",
"Event",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n",
"e",
".",
"buf",
"=",
"enc",
".",
"AppendDuration",
"(",
... | // Dur adds the field key with duration d stored as zerolog.DurationFieldUnit.
// If zerolog.DurationFieldInteger is true, durations are rendered as integer
// instead of float. | [
"Dur",
"adds",
"the",
"field",
"key",
"with",
"duration",
"d",
"stored",
"as",
"zerolog",
".",
"DurationFieldUnit",
".",
"If",
"zerolog",
".",
"DurationFieldInteger",
"is",
"true",
"durations",
"are",
"rendered",
"as",
"integer",
"instead",
"of",
"float",
"."
... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/event.go#L616-L622 | train |
rs/zerolog | event.go | Durs | func (e *Event) Durs(key string, d []time.Duration) *Event {
if e == nil {
return e
}
e.buf = enc.AppendDurations(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger)
return e
} | go | func (e *Event) Durs(key string, d []time.Duration) *Event {
if e == nil {
return e
}
e.buf = enc.AppendDurations(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger)
return e
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"Durs",
"(",
"key",
"string",
",",
"d",
"[",
"]",
"time",
".",
"Duration",
")",
"*",
"Event",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n",
"e",
".",
"buf",
"=",
"enc",
".",
"AppendDura... | // Durs adds the field key with duration d stored as zerolog.DurationFieldUnit.
// If zerolog.DurationFieldInteger is true, durations are rendered as integer
// instead of float. | [
"Durs",
"adds",
"the",
"field",
"key",
"with",
"duration",
"d",
"stored",
"as",
"zerolog",
".",
"DurationFieldUnit",
".",
"If",
"zerolog",
".",
"DurationFieldInteger",
"is",
"true",
"durations",
"are",
"rendered",
"as",
"integer",
"instead",
"of",
"float",
"."... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/event.go#L627-L633 | train |
rs/zerolog | event.go | Interface | func (e *Event) Interface(key string, i interface{}) *Event {
if e == nil {
return e
}
if obj, ok := i.(LogObjectMarshaler); ok {
return e.Object(key, obj)
}
e.buf = enc.AppendInterface(enc.AppendKey(e.buf, key), i)
return e
} | go | func (e *Event) Interface(key string, i interface{}) *Event {
if e == nil {
return e
}
if obj, ok := i.(LogObjectMarshaler); ok {
return e.Object(key, obj)
}
e.buf = enc.AppendInterface(enc.AppendKey(e.buf, key), i)
return e
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"Interface",
"(",
"key",
"string",
",",
"i",
"interface",
"{",
"}",
")",
"*",
"Event",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n",
"if",
"obj",
",",
"ok",
":=",
"i",
".",
"(",
"LogObj... | // Interface adds the field key with i marshaled using reflection. | [
"Interface",
"adds",
"the",
"field",
"key",
"with",
"i",
"marshaled",
"using",
"reflection",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/event.go#L651-L660 | train |
rs/zerolog | event.go | IPAddr | func (e *Event) IPAddr(key string, ip net.IP) *Event {
if e == nil {
return e
}
e.buf = enc.AppendIPAddr(enc.AppendKey(e.buf, key), ip)
return e
} | go | func (e *Event) IPAddr(key string, ip net.IP) *Event {
if e == nil {
return e
}
e.buf = enc.AppendIPAddr(enc.AppendKey(e.buf, key), ip)
return e
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"IPAddr",
"(",
"key",
"string",
",",
"ip",
"net",
".",
"IP",
")",
"*",
"Event",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n",
"e",
".",
"buf",
"=",
"enc",
".",
"AppendIPAddr",
"(",
"enc... | // IPAddr adds IPv4 or IPv6 Address to the event | [
"IPAddr",
"adds",
"IPv4",
"or",
"IPv6",
"Address",
"to",
"the",
"event"
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/event.go#L680-L686 | train |
rs/zerolog | event.go | MACAddr | func (e *Event) MACAddr(key string, ha net.HardwareAddr) *Event {
if e == nil {
return e
}
e.buf = enc.AppendMACAddr(enc.AppendKey(e.buf, key), ha)
return e
} | go | func (e *Event) MACAddr(key string, ha net.HardwareAddr) *Event {
if e == nil {
return e
}
e.buf = enc.AppendMACAddr(enc.AppendKey(e.buf, key), ha)
return e
} | [
"func",
"(",
"e",
"*",
"Event",
")",
"MACAddr",
"(",
"key",
"string",
",",
"ha",
"net",
".",
"HardwareAddr",
")",
"*",
"Event",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n",
"e",
".",
"buf",
"=",
"enc",
".",
"AppendMACAddr",
... | // MACAddr adds MAC address to the event | [
"MACAddr",
"adds",
"MAC",
"address",
"to",
"the",
"event"
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/event.go#L698-L704 | train |
rs/zerolog | internal/json/bytes.go | AppendHex | func (Encoder) AppendHex(dst, s []byte) []byte {
dst = append(dst, '"')
for _, v := range s {
dst = append(dst, hex[v>>4], hex[v&0x0f])
}
return append(dst, '"')
} | go | func (Encoder) AppendHex(dst, s []byte) []byte {
dst = append(dst, '"')
for _, v := range s {
dst = append(dst, hex[v>>4], hex[v&0x0f])
}
return append(dst, '"')
} | [
"func",
"(",
"Encoder",
")",
"AppendHex",
"(",
"dst",
",",
"s",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"dst",
"=",
"append",
"(",
"dst",
",",
"'\"'",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"s",
"{",
"dst",
"=",
"append",
"(",
... | // AppendHex encodes the input bytes to a hex string and appends
// the encoded string to the input byte slice.
//
// The operation loops though each byte and encodes it as hex using
// the hex lookup table. | [
"AppendHex",
"encodes",
"the",
"input",
"bytes",
"to",
"a",
"hex",
"string",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
".",
"The",
"operation",
"loops",
"though",
"each",
"byte",
"and",
"encodes",
"it",
"as",
"hex... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/bytes.go#L23-L29 | train |
rs/zerolog | array.go | Arr | func Arr() *Array {
a := arrayPool.Get().(*Array)
a.buf = a.buf[:0]
return a
} | go | func Arr() *Array {
a := arrayPool.Get().(*Array)
a.buf = a.buf[:0]
return a
} | [
"func",
"Arr",
"(",
")",
"*",
"Array",
"{",
"a",
":=",
"arrayPool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"Array",
")",
"\n",
"a",
".",
"buf",
"=",
"a",
".",
"buf",
"[",
":",
"0",
"]",
"\n",
"return",
"a",
"\n",
"}"
] | // Arr creates an array to be added to an Event or Context. | [
"Arr",
"creates",
"an",
"array",
"to",
"be",
"added",
"to",
"an",
"Event",
"or",
"Context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L38-L42 | train |
rs/zerolog | array.go | Object | func (a *Array) Object(obj LogObjectMarshaler) *Array {
e := Dict()
obj.MarshalZerologObject(e)
e.buf = enc.AppendEndMarker(e.buf)
a.buf = append(enc.AppendArrayDelim(a.buf), e.buf...)
putEvent(e)
return a
} | go | func (a *Array) Object(obj LogObjectMarshaler) *Array {
e := Dict()
obj.MarshalZerologObject(e)
e.buf = enc.AppendEndMarker(e.buf)
a.buf = append(enc.AppendArrayDelim(a.buf), e.buf...)
putEvent(e)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Object",
"(",
"obj",
"LogObjectMarshaler",
")",
"*",
"Array",
"{",
"e",
":=",
"Dict",
"(",
")",
"\n",
"obj",
".",
"MarshalZerologObject",
"(",
"e",
")",
"\n",
"e",
".",
"buf",
"=",
"enc",
".",
"AppendEndMarker",
... | // Object marshals an object that implement the LogObjectMarshaler
// interface and append append it to the array. | [
"Object",
"marshals",
"an",
"object",
"that",
"implement",
"the",
"LogObjectMarshaler",
"interface",
"and",
"append",
"append",
"it",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L61-L68 | train |
rs/zerolog | array.go | Str | func (a *Array) Str(val string) *Array {
a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), val)
return a
} | go | func (a *Array) Str(val string) *Array {
a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), val)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Str",
"(",
"val",
"string",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendString",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"val",
")",
"\n",
"return",
"a",
"\... | // Str append append the val as a string to the array. | [
"Str",
"append",
"append",
"the",
"val",
"as",
"a",
"string",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L71-L74 | train |
rs/zerolog | array.go | Bytes | func (a *Array) Bytes(val []byte) *Array {
a.buf = enc.AppendBytes(enc.AppendArrayDelim(a.buf), val)
return a
} | go | func (a *Array) Bytes(val []byte) *Array {
a.buf = enc.AppendBytes(enc.AppendArrayDelim(a.buf), val)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Bytes",
"(",
"val",
"[",
"]",
"byte",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendBytes",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"val",
")",
"\n",
"return"... | // Bytes append append the val as a string to the array. | [
"Bytes",
"append",
"append",
"the",
"val",
"as",
"a",
"string",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L77-L80 | train |
rs/zerolog | array.go | Hex | func (a *Array) Hex(val []byte) *Array {
a.buf = enc.AppendHex(enc.AppendArrayDelim(a.buf), val)
return a
} | go | func (a *Array) Hex(val []byte) *Array {
a.buf = enc.AppendHex(enc.AppendArrayDelim(a.buf), val)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Hex",
"(",
"val",
"[",
"]",
"byte",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendHex",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"val",
")",
"\n",
"return",
... | // Hex append append the val as a hex string to the array. | [
"Hex",
"append",
"append",
"the",
"val",
"as",
"a",
"hex",
"string",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L83-L86 | train |
rs/zerolog | array.go | Err | func (a *Array) Err(err error) *Array {
marshaled := ErrorMarshalFunc(err)
switch m := marshaled.(type) {
case LogObjectMarshaler:
e := newEvent(nil, 0)
e.buf = e.buf[:0]
e.appendObject(m)
a.buf = append(enc.AppendArrayDelim(a.buf), e.buf...)
putEvent(e)
case error:
a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), m.Error())
case string:
a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), m)
default:
a.buf = enc.AppendInterface(enc.AppendArrayDelim(a.buf), m)
}
return a
} | go | func (a *Array) Err(err error) *Array {
marshaled := ErrorMarshalFunc(err)
switch m := marshaled.(type) {
case LogObjectMarshaler:
e := newEvent(nil, 0)
e.buf = e.buf[:0]
e.appendObject(m)
a.buf = append(enc.AppendArrayDelim(a.buf), e.buf...)
putEvent(e)
case error:
a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), m.Error())
case string:
a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), m)
default:
a.buf = enc.AppendInterface(enc.AppendArrayDelim(a.buf), m)
}
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Err",
"(",
"err",
"error",
")",
"*",
"Array",
"{",
"marshaled",
":=",
"ErrorMarshalFunc",
"(",
"err",
")",
"\n",
"switch",
"m",
":=",
"marshaled",
".",
"(",
"type",
")",
"{",
"case",
"LogObjectMarshaler",
":",
"e... | // Err serializes and appends the err to the array. | [
"Err",
"serializes",
"and",
"appends",
"the",
"err",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L89-L107 | train |
rs/zerolog | array.go | Bool | func (a *Array) Bool(b bool) *Array {
a.buf = enc.AppendBool(enc.AppendArrayDelim(a.buf), b)
return a
} | go | func (a *Array) Bool(b bool) *Array {
a.buf = enc.AppendBool(enc.AppendArrayDelim(a.buf), b)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Bool",
"(",
"b",
"bool",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendBool",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"b",
")",
"\n",
"return",
"a",
"\n",
"... | // Bool append append the val as a bool to the array. | [
"Bool",
"append",
"append",
"the",
"val",
"as",
"a",
"bool",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L110-L113 | train |
rs/zerolog | array.go | Int | func (a *Array) Int(i int) *Array {
a.buf = enc.AppendInt(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Int(i int) *Array {
a.buf = enc.AppendInt(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Int",
"(",
"i",
"int",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendInt",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n",
"}"
... | // Int append append i as a int to the array. | [
"Int",
"append",
"append",
"i",
"as",
"a",
"int",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L116-L119 | train |
rs/zerolog | array.go | Int8 | func (a *Array) Int8(i int8) *Array {
a.buf = enc.AppendInt8(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Int8(i int8) *Array {
a.buf = enc.AppendInt8(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Int8",
"(",
"i",
"int8",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendInt8",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n",
"... | // Int8 append append i as a int8 to the array. | [
"Int8",
"append",
"append",
"i",
"as",
"a",
"int8",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L122-L125 | train |
rs/zerolog | array.go | Int16 | func (a *Array) Int16(i int16) *Array {
a.buf = enc.AppendInt16(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Int16(i int16) *Array {
a.buf = enc.AppendInt16(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Int16",
"(",
"i",
"int16",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendInt16",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n",
... | // Int16 append append i as a int16 to the array. | [
"Int16",
"append",
"append",
"i",
"as",
"a",
"int16",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L128-L131 | train |
rs/zerolog | array.go | Int32 | func (a *Array) Int32(i int32) *Array {
a.buf = enc.AppendInt32(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Int32(i int32) *Array {
a.buf = enc.AppendInt32(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Int32",
"(",
"i",
"int32",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendInt32",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n",
... | // Int32 append append i as a int32 to the array. | [
"Int32",
"append",
"append",
"i",
"as",
"a",
"int32",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L134-L137 | train |
rs/zerolog | array.go | Int64 | func (a *Array) Int64(i int64) *Array {
a.buf = enc.AppendInt64(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Int64(i int64) *Array {
a.buf = enc.AppendInt64(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Int64",
"(",
"i",
"int64",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendInt64",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n",
... | // Int64 append append i as a int64 to the array. | [
"Int64",
"append",
"append",
"i",
"as",
"a",
"int64",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L140-L143 | train |
rs/zerolog | array.go | Uint | func (a *Array) Uint(i uint) *Array {
a.buf = enc.AppendUint(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Uint(i uint) *Array {
a.buf = enc.AppendUint(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Uint",
"(",
"i",
"uint",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendUint",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n",
"... | // Uint append append i as a uint to the array. | [
"Uint",
"append",
"append",
"i",
"as",
"a",
"uint",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L146-L149 | train |
rs/zerolog | array.go | Uint8 | func (a *Array) Uint8(i uint8) *Array {
a.buf = enc.AppendUint8(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Uint8(i uint8) *Array {
a.buf = enc.AppendUint8(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Uint8",
"(",
"i",
"uint8",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendUint8",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n",
... | // Uint8 append append i as a uint8 to the array. | [
"Uint8",
"append",
"append",
"i",
"as",
"a",
"uint8",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L152-L155 | train |
rs/zerolog | array.go | Uint16 | func (a *Array) Uint16(i uint16) *Array {
a.buf = enc.AppendUint16(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Uint16(i uint16) *Array {
a.buf = enc.AppendUint16(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Uint16",
"(",
"i",
"uint16",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendUint16",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n... | // Uint16 append append i as a uint16 to the array. | [
"Uint16",
"append",
"append",
"i",
"as",
"a",
"uint16",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L158-L161 | train |
rs/zerolog | array.go | Uint32 | func (a *Array) Uint32(i uint32) *Array {
a.buf = enc.AppendUint32(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Uint32(i uint32) *Array {
a.buf = enc.AppendUint32(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Uint32",
"(",
"i",
"uint32",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendUint32",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n... | // Uint32 append append i as a uint32 to the array. | [
"Uint32",
"append",
"append",
"i",
"as",
"a",
"uint32",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L164-L167 | train |
rs/zerolog | array.go | Uint64 | func (a *Array) Uint64(i uint64) *Array {
a.buf = enc.AppendUint64(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Uint64(i uint64) *Array {
a.buf = enc.AppendUint64(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Uint64",
"(",
"i",
"uint64",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendUint64",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n... | // Uint64 append append i as a uint64 to the array. | [
"Uint64",
"append",
"append",
"i",
"as",
"a",
"uint64",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L170-L173 | train |
rs/zerolog | array.go | Float32 | func (a *Array) Float32(f float32) *Array {
a.buf = enc.AppendFloat32(enc.AppendArrayDelim(a.buf), f)
return a
} | go | func (a *Array) Float32(f float32) *Array {
a.buf = enc.AppendFloat32(enc.AppendArrayDelim(a.buf), f)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Float32",
"(",
"f",
"float32",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendFloat32",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"f",
")",
"\n",
"return",
"a",
... | // Float32 append append f as a float32 to the array. | [
"Float32",
"append",
"append",
"f",
"as",
"a",
"float32",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L176-L179 | train |
rs/zerolog | array.go | Float64 | func (a *Array) Float64(f float64) *Array {
a.buf = enc.AppendFloat64(enc.AppendArrayDelim(a.buf), f)
return a
} | go | func (a *Array) Float64(f float64) *Array {
a.buf = enc.AppendFloat64(enc.AppendArrayDelim(a.buf), f)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Float64",
"(",
"f",
"float64",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendFloat64",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"f",
")",
"\n",
"return",
"a",
... | // Float64 append append f as a float64 to the array. | [
"Float64",
"append",
"append",
"f",
"as",
"a",
"float64",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L182-L185 | train |
rs/zerolog | array.go | Time | func (a *Array) Time(t time.Time) *Array {
a.buf = enc.AppendTime(enc.AppendArrayDelim(a.buf), t, TimeFieldFormat)
return a
} | go | func (a *Array) Time(t time.Time) *Array {
a.buf = enc.AppendTime(enc.AppendArrayDelim(a.buf), t, TimeFieldFormat)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Time",
"(",
"t",
"time",
".",
"Time",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendTime",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"t",
",",
"TimeFieldFormat",
... | // Time append append t formated as string using zerolog.TimeFieldFormat. | [
"Time",
"append",
"append",
"t",
"formated",
"as",
"string",
"using",
"zerolog",
".",
"TimeFieldFormat",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L188-L191 | train |
rs/zerolog | array.go | Dur | func (a *Array) Dur(d time.Duration) *Array {
a.buf = enc.AppendDuration(enc.AppendArrayDelim(a.buf), d, DurationFieldUnit, DurationFieldInteger)
return a
} | go | func (a *Array) Dur(d time.Duration) *Array {
a.buf = enc.AppendDuration(enc.AppendArrayDelim(a.buf), d, DurationFieldUnit, DurationFieldInteger)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Dur",
"(",
"d",
"time",
".",
"Duration",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendDuration",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"d",
",",
"DurationFie... | // Dur append append d to the array. | [
"Dur",
"append",
"append",
"d",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L194-L197 | train |
rs/zerolog | array.go | Interface | func (a *Array) Interface(i interface{}) *Array {
if obj, ok := i.(LogObjectMarshaler); ok {
return a.Object(obj)
}
a.buf = enc.AppendInterface(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Interface(i interface{}) *Array {
if obj, ok := i.(LogObjectMarshaler); ok {
return a.Object(obj)
}
a.buf = enc.AppendInterface(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Interface",
"(",
"i",
"interface",
"{",
"}",
")",
"*",
"Array",
"{",
"if",
"obj",
",",
"ok",
":=",
"i",
".",
"(",
"LogObjectMarshaler",
")",
";",
"ok",
"{",
"return",
"a",
".",
"Object",
"(",
"obj",
")",
"\... | // Interface append append i marshaled using reflection. | [
"Interface",
"append",
"append",
"i",
"marshaled",
"using",
"reflection",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L200-L206 | train |
rs/zerolog | array.go | IPAddr | func (a *Array) IPAddr(ip net.IP) *Array {
a.buf = enc.AppendIPAddr(enc.AppendArrayDelim(a.buf), ip)
return a
} | go | func (a *Array) IPAddr(ip net.IP) *Array {
a.buf = enc.AppendIPAddr(enc.AppendArrayDelim(a.buf), ip)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"IPAddr",
"(",
"ip",
"net",
".",
"IP",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendIPAddr",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"ip",
")",
"\n",
"return"... | // IPAddr adds IPv4 or IPv6 address to the array | [
"IPAddr",
"adds",
"IPv4",
"or",
"IPv6",
"address",
"to",
"the",
"array"
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L209-L212 | train |
rs/zerolog | internal/json/string.go | AppendStrings | func (e Encoder) AppendStrings(dst []byte, vals []string) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = e.AppendString(dst, vals[0])
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = e.AppendString(append(dst, ','), val)
}
}
dst = append(dst, ']')
return dst
} | go | func (e Encoder) AppendStrings(dst []byte, vals []string) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = e.AppendString(dst, vals[0])
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = e.AppendString(append(dst, ','), val)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendStrings",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",... | // AppendStrings encodes the input strings to json and
// appends the encoded string list to the input byte slice. | [
"AppendStrings",
"encodes",
"the",
"input",
"strings",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/string.go#L17-L30 | train |
rs/zerolog | internal/json/string.go | AppendString | func (Encoder) AppendString(dst []byte, s string) []byte {
// Start with a double quote.
dst = append(dst, '"')
// Loop through each character in the string.
for i := 0; i < len(s); i++ {
// Check if the character needs encoding. Control characters, slashes,
// and the double quote need json encoding. Bytes above the ascii
// boundary needs utf8 encoding.
if !noEscapeTable[s[i]] {
// We encountered a character that needs to be encoded. Switch
// to complex version of the algorithm.
dst = appendStringComplex(dst, s, i)
return append(dst, '"')
}
}
// The string has no need for encoding an therefore is directly
// appended to the byte slice.
dst = append(dst, s...)
// End with a double quote
return append(dst, '"')
} | go | func (Encoder) AppendString(dst []byte, s string) []byte {
// Start with a double quote.
dst = append(dst, '"')
// Loop through each character in the string.
for i := 0; i < len(s); i++ {
// Check if the character needs encoding. Control characters, slashes,
// and the double quote need json encoding. Bytes above the ascii
// boundary needs utf8 encoding.
if !noEscapeTable[s[i]] {
// We encountered a character that needs to be encoded. Switch
// to complex version of the algorithm.
dst = appendStringComplex(dst, s, i)
return append(dst, '"')
}
}
// The string has no need for encoding an therefore is directly
// appended to the byte slice.
dst = append(dst, s...)
// End with a double quote
return append(dst, '"')
} | [
"func",
"(",
"Encoder",
")",
"AppendString",
"(",
"dst",
"[",
"]",
"byte",
",",
"s",
"string",
")",
"[",
"]",
"byte",
"{",
"// Start with a double quote.",
"dst",
"=",
"append",
"(",
"dst",
",",
"'\"'",
")",
"\n",
"// Loop through each character in the string.... | // AppendString encodes the input string to json and appends
// the encoded string to the input byte slice.
//
// The operation loops though each byte in the string looking
// for characters that need json or utf8 encoding. If the string
// does not need encoding, then the string is appended in it's
// entirety to the byte slice.
// If we encounter a byte that does need encoding, switch up
// the operation and perform a byte-by-byte read-encode-append. | [
"AppendString",
"encodes",
"the",
"input",
"string",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
".",
"The",
"operation",
"loops",
"though",
"each",
"byte",
"in",
"the",
"string",
"looking",
"for",
"char... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/string.go#L41-L61 | train |
rs/zerolog | internal/json/string.go | appendStringComplex | func appendStringComplex(dst []byte, s string, i int) []byte {
start := 0
for i < len(s) {
b := s[i]
if b >= utf8.RuneSelf {
r, size := utf8.DecodeRuneInString(s[i:])
if r == utf8.RuneError && size == 1 {
// In case of error, first append previous simple characters to
// the byte slice if any and append a remplacement character code
// in place of the invalid sequence.
if start < i {
dst = append(dst, s[start:i]...)
}
dst = append(dst, `\ufffd`...)
i += size
start = i
continue
}
i += size
continue
}
if noEscapeTable[b] {
i++
continue
}
// We encountered a character that needs to be encoded.
// Let's append the previous simple characters to the byte slice
// and switch our operation to read and encode the remainder
// characters byte-by-byte.
if start < i {
dst = append(dst, s[start:i]...)
}
switch b {
case '"', '\\':
dst = append(dst, '\\', b)
case '\b':
dst = append(dst, '\\', 'b')
case '\f':
dst = append(dst, '\\', 'f')
case '\n':
dst = append(dst, '\\', 'n')
case '\r':
dst = append(dst, '\\', 'r')
case '\t':
dst = append(dst, '\\', 't')
default:
dst = append(dst, '\\', 'u', '0', '0', hex[b>>4], hex[b&0xF])
}
i++
start = i
}
if start < len(s) {
dst = append(dst, s[start:]...)
}
return dst
} | go | func appendStringComplex(dst []byte, s string, i int) []byte {
start := 0
for i < len(s) {
b := s[i]
if b >= utf8.RuneSelf {
r, size := utf8.DecodeRuneInString(s[i:])
if r == utf8.RuneError && size == 1 {
// In case of error, first append previous simple characters to
// the byte slice if any and append a remplacement character code
// in place of the invalid sequence.
if start < i {
dst = append(dst, s[start:i]...)
}
dst = append(dst, `\ufffd`...)
i += size
start = i
continue
}
i += size
continue
}
if noEscapeTable[b] {
i++
continue
}
// We encountered a character that needs to be encoded.
// Let's append the previous simple characters to the byte slice
// and switch our operation to read and encode the remainder
// characters byte-by-byte.
if start < i {
dst = append(dst, s[start:i]...)
}
switch b {
case '"', '\\':
dst = append(dst, '\\', b)
case '\b':
dst = append(dst, '\\', 'b')
case '\f':
dst = append(dst, '\\', 'f')
case '\n':
dst = append(dst, '\\', 'n')
case '\r':
dst = append(dst, '\\', 'r')
case '\t':
dst = append(dst, '\\', 't')
default:
dst = append(dst, '\\', 'u', '0', '0', hex[b>>4], hex[b&0xF])
}
i++
start = i
}
if start < len(s) {
dst = append(dst, s[start:]...)
}
return dst
} | [
"func",
"appendStringComplex",
"(",
"dst",
"[",
"]",
"byte",
",",
"s",
"string",
",",
"i",
"int",
")",
"[",
"]",
"byte",
"{",
"start",
":=",
"0",
"\n",
"for",
"i",
"<",
"len",
"(",
"s",
")",
"{",
"b",
":=",
"s",
"[",
"i",
"]",
"\n",
"if",
"... | // appendStringComplex is used by appendString to take over an in
// progress JSON string encoding that encountered a character that needs
// to be encoded. | [
"appendStringComplex",
"is",
"used",
"by",
"appendString",
"to",
"take",
"over",
"an",
"in",
"progress",
"JSON",
"string",
"encoding",
"that",
"encountered",
"a",
"character",
"that",
"needs",
"to",
"be",
"encoded",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/string.go#L66-L121 | train |
rs/zerolog | diode/internal/diodes/poller.go | WithPollingInterval | func WithPollingInterval(interval time.Duration) PollerConfigOption {
return PollerConfigOption(func(c *Poller) {
c.interval = interval
})
} | go | func WithPollingInterval(interval time.Duration) PollerConfigOption {
return PollerConfigOption(func(c *Poller) {
c.interval = interval
})
} | [
"func",
"WithPollingInterval",
"(",
"interval",
"time",
".",
"Duration",
")",
"PollerConfigOption",
"{",
"return",
"PollerConfigOption",
"(",
"func",
"(",
"c",
"*",
"Poller",
")",
"{",
"c",
".",
"interval",
"=",
"interval",
"\n",
"}",
")",
"\n",
"}"
] | // WithPollingInterval sets the interval at which the diode is queried
// for new data. The default is 10ms. | [
"WithPollingInterval",
"sets",
"the",
"interval",
"at",
"which",
"the",
"diode",
"is",
"queried",
"for",
"new",
"data",
".",
"The",
"default",
"is",
"10ms",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/poller.go#L26-L30 | train |
rs/zerolog | diode/internal/diodes/poller.go | NewPoller | func NewPoller(d Diode, opts ...PollerConfigOption) *Poller {
p := &Poller{
Diode: d,
interval: 10 * time.Millisecond,
ctx: context.Background(),
}
for _, o := range opts {
o(p)
}
return p
} | go | func NewPoller(d Diode, opts ...PollerConfigOption) *Poller {
p := &Poller{
Diode: d,
interval: 10 * time.Millisecond,
ctx: context.Background(),
}
for _, o := range opts {
o(p)
}
return p
} | [
"func",
"NewPoller",
"(",
"d",
"Diode",
",",
"opts",
"...",
"PollerConfigOption",
")",
"*",
"Poller",
"{",
"p",
":=",
"&",
"Poller",
"{",
"Diode",
":",
"d",
",",
"interval",
":",
"10",
"*",
"time",
".",
"Millisecond",
",",
"ctx",
":",
"context",
".",... | // NewPoller returns a new Poller that wraps the given diode. | [
"NewPoller",
"returns",
"a",
"new",
"Poller",
"that",
"wraps",
"the",
"given",
"diode",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/poller.go#L42-L54 | train |
rs/zerolog | diode/internal/diodes/poller.go | Next | func (p *Poller) Next() GenericDataType {
for {
data, ok := p.Diode.TryNext()
if !ok {
if p.isDone() {
return nil
}
time.Sleep(p.interval)
continue
}
return data
}
} | go | func (p *Poller) Next() GenericDataType {
for {
data, ok := p.Diode.TryNext()
if !ok {
if p.isDone() {
return nil
}
time.Sleep(p.interval)
continue
}
return data
}
} | [
"func",
"(",
"p",
"*",
"Poller",
")",
"Next",
"(",
")",
"GenericDataType",
"{",
"for",
"{",
"data",
",",
"ok",
":=",
"p",
".",
"Diode",
".",
"TryNext",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"if",
"p",
".",
"isDone",
"(",
")",
"{",
"return",
"... | // Next polls the diode until data is available or until the context is done.
// If the context is done, then nil will be returned. | [
"Next",
"polls",
"the",
"diode",
"until",
"data",
"is",
"available",
"or",
"until",
"the",
"context",
"is",
"done",
".",
"If",
"the",
"context",
"is",
"done",
"then",
"nil",
"will",
"be",
"returned",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/poller.go#L58-L71 | train |
rs/zerolog | diode/internal/diodes/one_to_one.go | NewOneToOne | func NewOneToOne(size int, alerter Alerter) *OneToOne {
if alerter == nil {
alerter = AlertFunc(func(int) {})
}
return &OneToOne{
buffer: make([]unsafe.Pointer, size),
alerter: alerter,
}
} | go | func NewOneToOne(size int, alerter Alerter) *OneToOne {
if alerter == nil {
alerter = AlertFunc(func(int) {})
}
return &OneToOne{
buffer: make([]unsafe.Pointer, size),
alerter: alerter,
}
} | [
"func",
"NewOneToOne",
"(",
"size",
"int",
",",
"alerter",
"Alerter",
")",
"*",
"OneToOne",
"{",
"if",
"alerter",
"==",
"nil",
"{",
"alerter",
"=",
"AlertFunc",
"(",
"func",
"(",
"int",
")",
"{",
"}",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"OneToOne"... | // NewOneToOne creates a new diode is meant to be used by a single reader and
// a single writer. The alerter is invoked on the read's go-routine. It is
// called when it notices that the writer go-routine has passed it and wrote
// over data. A nil can be used to ignore alerts. | [
"NewOneToOne",
"creates",
"a",
"new",
"diode",
"is",
"meant",
"to",
"be",
"used",
"by",
"a",
"single",
"reader",
"and",
"a",
"single",
"writer",
".",
"The",
"alerter",
"is",
"invoked",
"on",
"the",
"read",
"s",
"go",
"-",
"routine",
".",
"It",
"is",
... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/one_to_one.go#L44-L53 | train |
rs/zerolog | internal/json/base.go | AppendKey | func (e Encoder) AppendKey(dst []byte, key string) []byte {
if len(dst) > 1 && dst[len(dst)-1] != '{' {
dst = append(dst, ',')
}
dst = e.AppendString(dst, key)
return append(dst, ':')
} | go | func (e Encoder) AppendKey(dst []byte, key string) []byte {
if len(dst) > 1 && dst[len(dst)-1] != '{' {
dst = append(dst, ',')
}
dst = e.AppendString(dst, key)
return append(dst, ':')
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendKey",
"(",
"dst",
"[",
"]",
"byte",
",",
"key",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"dst",
")",
">",
"1",
"&&",
"dst",
"[",
"len",
"(",
"dst",
")",
"-",
"1",
"]",
"!=",
"'{'",
"{"... | // AppendKey appends a new key to the output JSON. | [
"AppendKey",
"appends",
"a",
"new",
"key",
"to",
"the",
"output",
"JSON",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/base.go#L6-L12 | train |
rs/zerolog | internal/json/time.go | AppendTime | func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte {
switch format {
case timeFormatUnix:
return e.AppendInt64(dst, t.Unix())
case timeFormatUnixMs:
return e.AppendInt64(dst, t.UnixNano()/1000000)
}
return append(t.AppendFormat(append(dst, '"'), format), '"')
} | go | func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte {
switch format {
case timeFormatUnix:
return e.AppendInt64(dst, t.Unix())
case timeFormatUnixMs:
return e.AppendInt64(dst, t.UnixNano()/1000000)
}
return append(t.AppendFormat(append(dst, '"'), format), '"')
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendTime",
"(",
"dst",
"[",
"]",
"byte",
",",
"t",
"time",
".",
"Time",
",",
"format",
"string",
")",
"[",
"]",
"byte",
"{",
"switch",
"format",
"{",
"case",
"timeFormatUnix",
":",
"return",
"e",
".",
"AppendInt64... | // AppendTime formats the input time with the given format
// and appends the encoded string to the input byte slice. | [
"AppendTime",
"formats",
"the",
"input",
"time",
"with",
"the",
"given",
"format",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/time.go#L16-L24 | train |
rs/zerolog | internal/json/time.go | AppendTimes | func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte {
switch format {
case timeFormatUnix:
return appendUnixTimes(dst, vals)
case timeFormatUnixMs:
return appendUnixMsTimes(dst, vals)
}
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = append(vals[0].AppendFormat(append(dst, '"'), format), '"')
if len(vals) > 1 {
for _, t := range vals[1:] {
dst = append(t.AppendFormat(append(dst, ',', '"'), format), '"')
}
}
dst = append(dst, ']')
return dst
} | go | func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte {
switch format {
case timeFormatUnix:
return appendUnixTimes(dst, vals)
case timeFormatUnixMs:
return appendUnixMsTimes(dst, vals)
}
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = append(vals[0].AppendFormat(append(dst, '"'), format), '"')
if len(vals) > 1 {
for _, t := range vals[1:] {
dst = append(t.AppendFormat(append(dst, ',', '"'), format), '"')
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"Encoder",
")",
"AppendTimes",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"time",
".",
"Time",
",",
"format",
"string",
")",
"[",
"]",
"byte",
"{",
"switch",
"format",
"{",
"case",
"timeFormatUnix",
":",
"return",
"appendUnixTime... | // AppendTimes converts the input times with the given format
// and appends the encoded string list to the input byte slice. | [
"AppendTimes",
"converts",
"the",
"input",
"times",
"with",
"the",
"given",
"format",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/time.go#L28-L47 | train |
rs/zerolog | internal/json/time.go | AppendDurations | func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = e.AppendDuration(dst, vals[0], unit, useInt)
if len(vals) > 1 {
for _, d := range vals[1:] {
dst = e.AppendDuration(append(dst, ','), d, unit, useInt)
}
}
dst = append(dst, ']')
return dst
} | go | func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = e.AppendDuration(dst, vals[0], unit, useInt)
if len(vals) > 1 {
for _, d := range vals[1:] {
dst = e.AppendDuration(append(dst, ','), d, unit, useInt)
}
}
dst = append(dst, ']')
return dst
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendDurations",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"time",
".",
"Duration",
",",
"unit",
"time",
".",
"Duration",
",",
"useInt",
"bool",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
... | // AppendDurations formats the input durations with the given unit & format
// and appends the encoded string list to the input byte slice. | [
"AppendDurations",
"formats",
"the",
"input",
"durations",
"with",
"the",
"given",
"unit",
"&",
"format",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/time.go#L90-L103 | train |
rs/zerolog | pkgerrors/stacktrace.go | Write | func (s *state) Write(b []byte) (n int, err error) {
s.b = b
return len(b), nil
} | go | func (s *state) Write(b []byte) (n int, err error) {
s.b = b
return len(b), nil
} | [
"func",
"(",
"s",
"*",
"state",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"s",
".",
"b",
"=",
"b",
"\n",
"return",
"len",
"(",
"b",
")",
",",
"nil",
"\n",
"}"
] | // Write implement fmt.Formatter interface. | [
"Write",
"implement",
"fmt",
".",
"Formatter",
"interface",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/pkgerrors/stacktrace.go#L18-L21 | train |
rs/zerolog | hlog/hlog.go | NewHandler | func NewHandler(log zerolog.Logger) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Create a copy of the logger (including internal context slice)
// to prevent data race when using UpdateContext.
l := log.With().Logger()
r = r.WithContext(l.WithContext(r.Context()))
next.ServeHTTP(w, r)
})
}
} | go | func NewHandler(log zerolog.Logger) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Create a copy of the logger (including internal context slice)
// to prevent data race when using UpdateContext.
l := log.With().Logger()
r = r.WithContext(l.WithContext(r.Context()))
next.ServeHTTP(w, r)
})
}
} | [
"func",
"NewHandler",
"(",
"log",
"zerolog",
".",
"Logger",
")",
"func",
"(",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"H... | // NewHandler injects log into requests context. | [
"NewHandler",
"injects",
"log",
"into",
"requests",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L23-L33 | train |
rs/zerolog | hlog/hlog.go | RequestHandler | func RequestHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
return c.Str(fieldKey, r.Method+" "+r.URL.String())
})
next.ServeHTTP(w, r)
})
}
} | go | func RequestHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
return c.Str(fieldKey, r.Method+" "+r.URL.String())
})
next.ServeHTTP(w, r)
})
}
} | [
"func",
"RequestHandler",
"(",
"fieldKey",
"string",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"Ha... | // RequestHandler adds the request method and URL as a field to the context's logger
// using fieldKey as field key. | [
"RequestHandler",
"adds",
"the",
"request",
"method",
"and",
"URL",
"as",
"a",
"field",
"to",
"the",
"context",
"s",
"logger",
"using",
"fieldKey",
"as",
"field",
"key",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L65-L75 | train |
rs/zerolog | hlog/hlog.go | RemoteAddrHandler | func RemoteAddrHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if host, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
return c.Str(fieldKey, host)
})
}
next.ServeHTTP(w, r)
})
}
} | go | func RemoteAddrHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if host, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
return c.Str(fieldKey, host)
})
}
next.ServeHTTP(w, r)
})
}
} | [
"func",
"RemoteAddrHandler",
"(",
"fieldKey",
"string",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
... | // RemoteAddrHandler adds the request's remote address as a field to the context's logger
// using fieldKey as field key. | [
"RemoteAddrHandler",
"adds",
"the",
"request",
"s",
"remote",
"address",
"as",
"a",
"field",
"to",
"the",
"context",
"s",
"logger",
"using",
"fieldKey",
"as",
"field",
"key",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L79-L91 | train |
rs/zerolog | hlog/hlog.go | UserAgentHandler | func UserAgentHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if ua := r.Header.Get("User-Agent"); ua != "" {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
return c.Str(fieldKey, ua)
})
}
next.ServeHTTP(w, r)
})
}
} | go | func UserAgentHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if ua := r.Header.Get("User-Agent"); ua != "" {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
return c.Str(fieldKey, ua)
})
}
next.ServeHTTP(w, r)
})
}
} | [
"func",
"UserAgentHandler",
"(",
"fieldKey",
"string",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"... | // UserAgentHandler adds the request's user-agent as a field to the context's logger
// using fieldKey as field key. | [
"UserAgentHandler",
"adds",
"the",
"request",
"s",
"user",
"-",
"agent",
"as",
"a",
"field",
"to",
"the",
"context",
"s",
"logger",
"using",
"fieldKey",
"as",
"field",
"key",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L95-L107 | train |
rs/zerolog | hlog/hlog.go | IDFromRequest | func IDFromRequest(r *http.Request) (id xid.ID, ok bool) {
if r == nil {
return
}
return IDFromCtx(r.Context())
} | go | func IDFromRequest(r *http.Request) (id xid.ID, ok bool) {
if r == nil {
return
}
return IDFromCtx(r.Context())
} | [
"func",
"IDFromRequest",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"id",
"xid",
".",
"ID",
",",
"ok",
"bool",
")",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"return",
"IDFromCtx",
"(",
"r",
".",
"Context",
"(",
")",
")... | // IDFromRequest returns the unique id associated to the request if any. | [
"IDFromRequest",
"returns",
"the",
"unique",
"id",
"associated",
"to",
"the",
"request",
"if",
"any",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L128-L133 | train |
rs/zerolog | hlog/hlog.go | AccessHandler | func AccessHandler(f func(r *http.Request, status, size int, duration time.Duration)) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
lw := mutil.WrapWriter(w)
next.ServeHTTP(lw, r)
f(r, lw.Status(), lw.BytesWritten(), time.Since(start))
})
}
} | go | func AccessHandler(f func(r *http.Request, status, size int, duration time.Duration)) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
lw := mutil.WrapWriter(w)
next.ServeHTTP(lw, r)
f(r, lw.Status(), lw.BytesWritten(), time.Since(start))
})
}
} | [
"func",
"AccessHandler",
"(",
"f",
"func",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"status",
",",
"size",
"int",
",",
"duration",
"time",
".",
"Duration",
")",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
... | // AccessHandler returns a handler that call f after each request. | [
"AccessHandler",
"returns",
"a",
"handler",
"that",
"call",
"f",
"after",
"each",
"request",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L175-L184 | train |
rebuy-de/aws-nuke | cmd/queue.go | List | func (i *Item) List() ([]resources.Resource, error) {
listers := resources.GetListers()
return listers[i.Type](i.Region.Session)
} | go | func (i *Item) List() ([]resources.Resource, error) {
listers := resources.GetListers()
return listers[i.Type](i.Region.Session)
} | [
"func",
"(",
"i",
"*",
"Item",
")",
"List",
"(",
")",
"(",
"[",
"]",
"resources",
".",
"Resource",
",",
"error",
")",
"{",
"listers",
":=",
"resources",
".",
"GetListers",
"(",
")",
"\n",
"return",
"listers",
"[",
"i",
".",
"Type",
"]",
"(",
"i",... | // List gets all resource items of the same resource type like the Item. | [
"List",
"gets",
"all",
"resource",
"items",
"of",
"the",
"same",
"resource",
"type",
"like",
"the",
"Item",
"."
] | 21582790b6806fd775aba073b0bbc27a111a15f0 | https://github.com/rebuy-de/aws-nuke/blob/21582790b6806fd775aba073b0bbc27a111a15f0/cmd/queue.go#L51-L54 | train |
wcharczuk/go-chart | util/math.go | Max | func (m mathUtil) Max(values ...float64) float64 {
if len(values) == 0 {
return 0
}
max := values[0]
for _, v := range values {
if max < v {
max = v
}
}
return max
} | go | func (m mathUtil) Max(values ...float64) float64 {
if len(values) == 0 {
return 0
}
max := values[0]
for _, v := range values {
if max < v {
max = v
}
}
return max
} | [
"func",
"(",
"m",
"mathUtil",
")",
"Max",
"(",
"values",
"...",
"float64",
")",
"float64",
"{",
"if",
"len",
"(",
"values",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"max",
":=",
"values",
"[",
"0",
"]",
"\n",
"for",
"_",
",",
"v",
... | // Max returns the maximum value of a group of floats. | [
"Max",
"returns",
"the",
"maximum",
"value",
"of",
"a",
"group",
"of",
"floats",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L29-L40 | train |
wcharczuk/go-chart | util/math.go | MinAndMax | func (m mathUtil) MinAndMax(values ...float64) (min float64, max float64) {
if len(values) == 0 {
return
}
min = values[0]
max = values[0]
for _, v := range values[1:] {
if max < v {
max = v
}
if min > v {
min = v
}
}
return
} | go | func (m mathUtil) MinAndMax(values ...float64) (min float64, max float64) {
if len(values) == 0 {
return
}
min = values[0]
max = values[0]
for _, v := range values[1:] {
if max < v {
max = v
}
if min > v {
min = v
}
}
return
} | [
"func",
"(",
"m",
"mathUtil",
")",
"MinAndMax",
"(",
"values",
"...",
"float64",
")",
"(",
"min",
"float64",
",",
"max",
"float64",
")",
"{",
"if",
"len",
"(",
"values",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"min",
"=",
"values",
"[",
"... | // MinAndMax returns both the min and max in one pass. | [
"MinAndMax",
"returns",
"both",
"the",
"min",
"and",
"max",
"in",
"one",
"pass",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L43-L58 | train |
wcharczuk/go-chart | util/math.go | GetRoundToForDelta | func (m mathUtil) GetRoundToForDelta(delta float64) float64 {
startingDeltaBound := math.Pow(10.0, 10.0)
for cursor := startingDeltaBound; cursor > 0; cursor /= 10.0 {
if delta > cursor {
return cursor / 10.0
}
}
return 0.0
} | go | func (m mathUtil) GetRoundToForDelta(delta float64) float64 {
startingDeltaBound := math.Pow(10.0, 10.0)
for cursor := startingDeltaBound; cursor > 0; cursor /= 10.0 {
if delta > cursor {
return cursor / 10.0
}
}
return 0.0
} | [
"func",
"(",
"m",
"mathUtil",
")",
"GetRoundToForDelta",
"(",
"delta",
"float64",
")",
"float64",
"{",
"startingDeltaBound",
":=",
"math",
".",
"Pow",
"(",
"10.0",
",",
"10.0",
")",
"\n",
"for",
"cursor",
":=",
"startingDeltaBound",
";",
"cursor",
">",
"0"... | // GetRoundToForDelta returns a `roundTo` value for a given delta. | [
"GetRoundToForDelta",
"returns",
"a",
"roundTo",
"value",
"for",
"a",
"given",
"delta",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L61-L70 | train |
wcharczuk/go-chart | util/math.go | RoundUp | func (m mathUtil) RoundUp(value, roundTo float64) float64 {
if roundTo < 0.000000000000001 {
return value
}
d1 := math.Ceil(value / roundTo)
return d1 * roundTo
} | go | func (m mathUtil) RoundUp(value, roundTo float64) float64 {
if roundTo < 0.000000000000001 {
return value
}
d1 := math.Ceil(value / roundTo)
return d1 * roundTo
} | [
"func",
"(",
"m",
"mathUtil",
")",
"RoundUp",
"(",
"value",
",",
"roundTo",
"float64",
")",
"float64",
"{",
"if",
"roundTo",
"<",
"0.000000000000001",
"{",
"return",
"value",
"\n",
"}",
"\n",
"d1",
":=",
"math",
".",
"Ceil",
"(",
"value",
"/",
"roundTo... | // RoundUp rounds up to a given roundTo value. | [
"RoundUp",
"rounds",
"up",
"to",
"a",
"given",
"roundTo",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L73-L79 | train |
wcharczuk/go-chart | util/math.go | RoundDown | func (m mathUtil) RoundDown(value, roundTo float64) float64 {
if roundTo < 0.000000000000001 {
return value
}
d1 := math.Floor(value / roundTo)
return d1 * roundTo
} | go | func (m mathUtil) RoundDown(value, roundTo float64) float64 {
if roundTo < 0.000000000000001 {
return value
}
d1 := math.Floor(value / roundTo)
return d1 * roundTo
} | [
"func",
"(",
"m",
"mathUtil",
")",
"RoundDown",
"(",
"value",
",",
"roundTo",
"float64",
")",
"float64",
"{",
"if",
"roundTo",
"<",
"0.000000000000001",
"{",
"return",
"value",
"\n",
"}",
"\n",
"d1",
":=",
"math",
".",
"Floor",
"(",
"value",
"/",
"roun... | // RoundDown rounds down to a given roundTo value. | [
"RoundDown",
"rounds",
"down",
"to",
"a",
"given",
"roundTo",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L82-L88 | train |
wcharczuk/go-chart | util/math.go | MinInt | func (m mathUtil) MinInt(values ...int) int {
min := math.MaxInt32
for _, v := range values {
if v < min {
min = v
}
}
return min
} | go | func (m mathUtil) MinInt(values ...int) int {
min := math.MaxInt32
for _, v := range values {
if v < min {
min = v
}
}
return min
} | [
"func",
"(",
"m",
"mathUtil",
")",
"MinInt",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"min",
":=",
"math",
".",
"MaxInt32",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"if",
"v",
"<",
"min",
"{",
"min",
"=",
"v",
"\n",
"}",
... | // MinInt returns the minimum of a set of integers. | [
"MinInt",
"returns",
"the",
"minimum",
"of",
"a",
"set",
"of",
"integers",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L106-L114 | train |
wcharczuk/go-chart | util/math.go | MaxInt | func (m mathUtil) MaxInt(values ...int) int {
max := math.MinInt32
for _, v := range values {
if v > max {
max = v
}
}
return max
} | go | func (m mathUtil) MaxInt(values ...int) int {
max := math.MinInt32
for _, v := range values {
if v > max {
max = v
}
}
return max
} | [
"func",
"(",
"m",
"mathUtil",
")",
"MaxInt",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"max",
":=",
"math",
".",
"MinInt32",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"if",
"v",
">",
"max",
"{",
"max",
"=",
"v",
"\n",
"}",
... | // MaxInt returns the maximum of a set of integers. | [
"MaxInt",
"returns",
"the",
"maximum",
"of",
"a",
"set",
"of",
"integers",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L117-L125 | train |
wcharczuk/go-chart | util/math.go | Mean | func (m mathUtil) Mean(values ...float64) float64 {
return m.Sum(values...) / float64(len(values))
} | go | func (m mathUtil) Mean(values ...float64) float64 {
return m.Sum(values...) / float64(len(values))
} | [
"func",
"(",
"m",
"mathUtil",
")",
"Mean",
"(",
"values",
"...",
"float64",
")",
"float64",
"{",
"return",
"m",
".",
"Sum",
"(",
"values",
"...",
")",
"/",
"float64",
"(",
"len",
"(",
"values",
")",
")",
"\n",
"}"
] | // Mean returns the mean of a set of values | [
"Mean",
"returns",
"the",
"mean",
"of",
"a",
"set",
"of",
"values"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L144-L146 | train |
wcharczuk/go-chart | util/math.go | MeanInt | func (m mathUtil) MeanInt(values ...int) int {
return m.SumInt(values...) / len(values)
} | go | func (m mathUtil) MeanInt(values ...int) int {
return m.SumInt(values...) / len(values)
} | [
"func",
"(",
"m",
"mathUtil",
")",
"MeanInt",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"return",
"m",
".",
"SumInt",
"(",
"values",
"...",
")",
"/",
"len",
"(",
"values",
")",
"\n",
"}"
] | // MeanInt returns the mean of a set of integer values. | [
"MeanInt",
"returns",
"the",
"mean",
"of",
"a",
"set",
"of",
"integer",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L149-L151 | train |
wcharczuk/go-chart | util/math.go | Sum | func (m mathUtil) Sum(values ...float64) float64 {
var total float64
for _, v := range values {
total += v
}
return total
} | go | func (m mathUtil) Sum(values ...float64) float64 {
var total float64
for _, v := range values {
total += v
}
return total
} | [
"func",
"(",
"m",
"mathUtil",
")",
"Sum",
"(",
"values",
"...",
"float64",
")",
"float64",
"{",
"var",
"total",
"float64",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"total",
"+=",
"v",
"\n",
"}",
"\n",
"return",
"total",
"\n",
"}"
] | // Sum sums a set of values. | [
"Sum",
"sums",
"a",
"set",
"of",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L154-L160 | train |
wcharczuk/go-chart | util/math.go | SumInt | func (m mathUtil) SumInt(values ...int) int {
var total int
for _, v := range values {
total += v
}
return total
} | go | func (m mathUtil) SumInt(values ...int) int {
var total int
for _, v := range values {
total += v
}
return total
} | [
"func",
"(",
"m",
"mathUtil",
")",
"SumInt",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"var",
"total",
"int",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"total",
"+=",
"v",
"\n",
"}",
"\n",
"return",
"total",
"\n",
"}"
] | // SumInt sums a set of values. | [
"SumInt",
"sums",
"a",
"set",
"of",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L163-L169 | train |
wcharczuk/go-chart | util/math.go | RadiansToDegrees | func (m mathUtil) RadiansToDegrees(value float64) float64 {
return math.Mod(value, _2pi) * _r2d
} | go | func (m mathUtil) RadiansToDegrees(value float64) float64 {
return math.Mod(value, _2pi) * _r2d
} | [
"func",
"(",
"m",
"mathUtil",
")",
"RadiansToDegrees",
"(",
"value",
"float64",
")",
"float64",
"{",
"return",
"math",
".",
"Mod",
"(",
"value",
",",
"_2pi",
")",
"*",
"_r2d",
"\n",
"}"
] | // RadiansToDegrees translates a radian value to a degree value. | [
"RadiansToDegrees",
"translates",
"a",
"radian",
"value",
"to",
"a",
"degree",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L186-L188 | train |
wcharczuk/go-chart | util/math.go | RadianAdd | func (m mathUtil) RadianAdd(base, delta float64) float64 {
value := base + delta
if value > _2pi {
return math.Mod(value, _2pi)
} else if value < 0 {
return math.Mod(_2pi+value, _2pi)
}
return value
} | go | func (m mathUtil) RadianAdd(base, delta float64) float64 {
value := base + delta
if value > _2pi {
return math.Mod(value, _2pi)
} else if value < 0 {
return math.Mod(_2pi+value, _2pi)
}
return value
} | [
"func",
"(",
"m",
"mathUtil",
")",
"RadianAdd",
"(",
"base",
",",
"delta",
"float64",
")",
"float64",
"{",
"value",
":=",
"base",
"+",
"delta",
"\n",
"if",
"value",
">",
"_2pi",
"{",
"return",
"math",
".",
"Mod",
"(",
"value",
",",
"_2pi",
")",
"\n... | // RadianAdd adds a delta to a base in radians. | [
"RadianAdd",
"adds",
"a",
"delta",
"to",
"a",
"base",
"in",
"radians",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L196-L204 | train |
wcharczuk/go-chart | util/math.go | DegreesAdd | func (m mathUtil) DegreesAdd(baseDegrees, deltaDegrees float64) float64 {
value := baseDegrees + deltaDegrees
if value > _2pi {
return math.Mod(value, 360.0)
} else if value < 0 {
return math.Mod(360.0+value, 360.0)
}
return value
} | go | func (m mathUtil) DegreesAdd(baseDegrees, deltaDegrees float64) float64 {
value := baseDegrees + deltaDegrees
if value > _2pi {
return math.Mod(value, 360.0)
} else if value < 0 {
return math.Mod(360.0+value, 360.0)
}
return value
} | [
"func",
"(",
"m",
"mathUtil",
")",
"DegreesAdd",
"(",
"baseDegrees",
",",
"deltaDegrees",
"float64",
")",
"float64",
"{",
"value",
":=",
"baseDegrees",
"+",
"deltaDegrees",
"\n",
"if",
"value",
">",
"_2pi",
"{",
"return",
"math",
".",
"Mod",
"(",
"value",
... | // DegreesAdd adds a delta to a base in radians. | [
"DegreesAdd",
"adds",
"a",
"delta",
"to",
"a",
"base",
"in",
"radians",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L207-L215 | train |
wcharczuk/go-chart | util/math.go | CirclePoint | func (m mathUtil) CirclePoint(cx, cy int, radius, thetaRadians float64) (x, y int) {
x = cx + int(radius*math.Sin(thetaRadians))
y = cy - int(radius*math.Cos(thetaRadians))
return
} | go | func (m mathUtil) CirclePoint(cx, cy int, radius, thetaRadians float64) (x, y int) {
x = cx + int(radius*math.Sin(thetaRadians))
y = cy - int(radius*math.Cos(thetaRadians))
return
} | [
"func",
"(",
"m",
"mathUtil",
")",
"CirclePoint",
"(",
"cx",
",",
"cy",
"int",
",",
"radius",
",",
"thetaRadians",
"float64",
")",
"(",
"x",
",",
"y",
"int",
")",
"{",
"x",
"=",
"cx",
"+",
"int",
"(",
"radius",
"*",
"math",
".",
"Sin",
"(",
"th... | // CirclePoint returns the absolute position of a circle diameter point given
// by the radius and the theta. | [
"CirclePoint",
"returns",
"the",
"absolute",
"position",
"of",
"a",
"circle",
"diameter",
"point",
"given",
"by",
"the",
"radius",
"and",
"the",
"theta",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L224-L228 | train |
wcharczuk/go-chart | seq/seq.go | Array | func (s Seq) Array() (output []float64) {
if s.Len() == 0 {
return
}
output = make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
output[i] = s.GetValue(i)
}
return
} | go | func (s Seq) Array() (output []float64) {
if s.Len() == 0 {
return
}
output = make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
output[i] = s.GetValue(i)
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"Array",
"(",
")",
"(",
"output",
"[",
"]",
"float64",
")",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"output",
"=",
"make",
"(",
"[",
"]",
"float64",
",",
"s",
".",
"Le... | // Array enumerates the seq into a slice. | [
"Array",
"enumerates",
"the",
"seq",
"into",
"a",
"slice",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L30-L40 | train |
wcharczuk/go-chart | seq/seq.go | Each | func (s Seq) Each(mapfn func(int, float64)) {
for i := 0; i < s.Len(); i++ {
mapfn(i, s.GetValue(i))
}
} | go | func (s Seq) Each(mapfn func(int, float64)) {
for i := 0; i < s.Len(); i++ {
mapfn(i, s.GetValue(i))
}
} | [
"func",
"(",
"s",
"Seq",
")",
"Each",
"(",
"mapfn",
"func",
"(",
"int",
",",
"float64",
")",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"s",
".",
"Len",
"(",
")",
";",
"i",
"++",
"{",
"mapfn",
"(",
"i",
",",
"s",
".",
"GetValue",
"("... | // Each applies the `mapfn` to all values in the value provider. | [
"Each",
"applies",
"the",
"mapfn",
"to",
"all",
"values",
"in",
"the",
"value",
"provider",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L43-L47 | train |
wcharczuk/go-chart | seq/seq.go | Map | func (s Seq) Map(mapfn func(i int, v float64) float64) Seq {
output := make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
mapfn(i, s.GetValue(i))
}
return Seq{Array(output)}
} | go | func (s Seq) Map(mapfn func(i int, v float64) float64) Seq {
output := make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
mapfn(i, s.GetValue(i))
}
return Seq{Array(output)}
} | [
"func",
"(",
"s",
"Seq",
")",
"Map",
"(",
"mapfn",
"func",
"(",
"i",
"int",
",",
"v",
"float64",
")",
"float64",
")",
"Seq",
"{",
"output",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"s",
".",
"Len",
"(",
")",
")",
"\n",
"for",
"i",
":=",
... | // Map applies the `mapfn` to all values in the value provider,
// returning a new seq. | [
"Map",
"applies",
"the",
"mapfn",
"to",
"all",
"values",
"in",
"the",
"value",
"provider",
"returning",
"a",
"new",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L51-L57 | train |
wcharczuk/go-chart | seq/seq.go | FoldRight | func (s Seq) FoldRight(mapfn func(i int, v0, v float64) float64) (v0 float64) {
if s.Len() == 0 {
return 0
}
if s.Len() == 1 {
return s.GetValue(0)
}
v0 = s.GetValue(s.Len() - 1)
for i := s.Len() - 2; i >= 0; i-- {
v0 = mapfn(i, v0, s.GetValue(i))
}
return
} | go | func (s Seq) FoldRight(mapfn func(i int, v0, v float64) float64) (v0 float64) {
if s.Len() == 0 {
return 0
}
if s.Len() == 1 {
return s.GetValue(0)
}
v0 = s.GetValue(s.Len() - 1)
for i := s.Len() - 2; i >= 0; i-- {
v0 = mapfn(i, v0, s.GetValue(i))
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"FoldRight",
"(",
"mapfn",
"func",
"(",
"i",
"int",
",",
"v0",
",",
"v",
"float64",
")",
"float64",
")",
"(",
"v0",
"float64",
")",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
... | // FoldRight collapses a seq from right to left. | [
"FoldRight",
"collapses",
"a",
"seq",
"from",
"right",
"to",
"left",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L77-L91 | train |
wcharczuk/go-chart | seq/seq.go | Min | func (s Seq) Min() float64 {
if s.Len() == 0 {
return 0
}
min := s.GetValue(0)
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value < min {
min = value
}
}
return min
} | go | func (s Seq) Min() float64 {
if s.Len() == 0 {
return 0
}
min := s.GetValue(0)
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value < min {
min = value
}
}
return min
} | [
"func",
"(",
"s",
"Seq",
")",
"Min",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"min",
":=",
"s",
".",
"GetValue",
"(",
"0",
")",
"\n",
"var",
"value",
"float64",
"\n",
"for",
... | // Min returns the minimum value in the seq. | [
"Min",
"returns",
"the",
"minimum",
"value",
"in",
"the",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L94-L107 | train |
wcharczuk/go-chart | seq/seq.go | Max | func (s Seq) Max() float64 {
if s.Len() == 0 {
return 0
}
max := s.GetValue(0)
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value > max {
max = value
}
}
return max
} | go | func (s Seq) Max() float64 {
if s.Len() == 0 {
return 0
}
max := s.GetValue(0)
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value > max {
max = value
}
}
return max
} | [
"func",
"(",
"s",
"Seq",
")",
"Max",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"max",
":=",
"s",
".",
"GetValue",
"(",
"0",
")",
"\n",
"var",
"value",
"float64",
"\n",
"for",
... | // Max returns the maximum value in the seq. | [
"Max",
"returns",
"the",
"maximum",
"value",
"in",
"the",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L110-L123 | train |
wcharczuk/go-chart | seq/seq.go | MinMax | func (s Seq) MinMax() (min, max float64) {
if s.Len() == 0 {
return
}
min = s.GetValue(0)
max = min
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value < min {
min = value
}
if value > max {
max = value
}
}
return
} | go | func (s Seq) MinMax() (min, max float64) {
if s.Len() == 0 {
return
}
min = s.GetValue(0)
max = min
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value < min {
min = value
}
if value > max {
max = value
}
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"MinMax",
"(",
")",
"(",
"min",
",",
"max",
"float64",
")",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"min",
"=",
"s",
".",
"GetValue",
"(",
"0",
")",
"\n",
"max",
"=",
... | // MinMax returns the minimum and the maximum in one pass. | [
"MinMax",
"returns",
"the",
"minimum",
"and",
"the",
"maximum",
"in",
"one",
"pass",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L126-L143 | train |
wcharczuk/go-chart | seq/seq.go | Sort | func (s Seq) Sort() Seq {
if s.Len() == 0 {
return s
}
values := s.Array()
sort.Float64s(values)
return Seq{Provider: Array(values)}
} | go | func (s Seq) Sort() Seq {
if s.Len() == 0 {
return s
}
values := s.Array()
sort.Float64s(values)
return Seq{Provider: Array(values)}
} | [
"func",
"(",
"s",
"Seq",
")",
"Sort",
"(",
")",
"Seq",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"s",
"\n",
"}",
"\n",
"values",
":=",
"s",
".",
"Array",
"(",
")",
"\n",
"sort",
".",
"Float64s",
"(",
"values",
")",
"\n... | // Sort returns the seq sorted in ascending order.
// This fully enumerates the seq. | [
"Sort",
"returns",
"the",
"seq",
"sorted",
"in",
"ascending",
"order",
".",
"This",
"fully",
"enumerates",
"the",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L147-L154 | train |
wcharczuk/go-chart | seq/seq.go | Median | func (s Seq) Median() (median float64) {
l := s.Len()
if l == 0 {
return
}
sorted := s.Sort()
if l%2 == 0 {
v0 := sorted.GetValue(l/2 - 1)
v1 := sorted.GetValue(l/2 + 1)
median = (v0 + v1) / 2
} else {
median = float64(sorted.GetValue(l << 1))
}
return
} | go | func (s Seq) Median() (median float64) {
l := s.Len()
if l == 0 {
return
}
sorted := s.Sort()
if l%2 == 0 {
v0 := sorted.GetValue(l/2 - 1)
v1 := sorted.GetValue(l/2 + 1)
median = (v0 + v1) / 2
} else {
median = float64(sorted.GetValue(l << 1))
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"Median",
"(",
")",
"(",
"median",
"float64",
")",
"{",
"l",
":=",
"s",
".",
"Len",
"(",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"sorted",
":=",
"s",
".",
"Sort",
"(",
")",
"\n",
"if"... | // Median returns the median or middle value in the sorted seq. | [
"Median",
"returns",
"the",
"median",
"or",
"middle",
"value",
"in",
"the",
"sorted",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L157-L173 | train |
wcharczuk/go-chart | seq/seq.go | Sum | func (s Seq) Sum() (accum float64) {
if s.Len() == 0 {
return 0
}
for i := 0; i < s.Len(); i++ {
accum += s.GetValue(i)
}
return
} | go | func (s Seq) Sum() (accum float64) {
if s.Len() == 0 {
return 0
}
for i := 0; i < s.Len(); i++ {
accum += s.GetValue(i)
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"Sum",
"(",
")",
"(",
"accum",
"float64",
")",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"s",
".",
"Len",
"(",
")",
";",
"... | // Sum adds all the elements of a series together. | [
"Sum",
"adds",
"all",
"the",
"elements",
"of",
"a",
"series",
"together",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L176-L185 | train |
wcharczuk/go-chart | seq/seq.go | Average | func (s Seq) Average() float64 {
if s.Len() == 0 {
return 0
}
return s.Sum() / float64(s.Len())
} | go | func (s Seq) Average() float64 {
if s.Len() == 0 {
return 0
}
return s.Sum() / float64(s.Len())
} | [
"func",
"(",
"s",
"Seq",
")",
"Average",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"return",
"s",
".",
"Sum",
"(",
")",
"/",
"float64",
"(",
"s",
".",
"Len",
"(",
")",
")",
... | // Average returns the float average of the values in the buffer. | [
"Average",
"returns",
"the",
"float",
"average",
"of",
"the",
"values",
"in",
"the",
"buffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L188-L194 | train |
wcharczuk/go-chart | seq/seq.go | Variance | func (s Seq) Variance() float64 {
if s.Len() == 0 {
return 0
}
m := s.Average()
var variance, v float64
for i := 0; i < s.Len(); i++ {
v = s.GetValue(i)
variance += (v - m) * (v - m)
}
return variance / float64(s.Len())
} | go | func (s Seq) Variance() float64 {
if s.Len() == 0 {
return 0
}
m := s.Average()
var variance, v float64
for i := 0; i < s.Len(); i++ {
v = s.GetValue(i)
variance += (v - m) * (v - m)
}
return variance / float64(s.Len())
} | [
"func",
"(",
"s",
"Seq",
")",
"Variance",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"m",
":=",
"s",
".",
"Average",
"(",
")",
"\n",
"var",
"variance",
",",
"v",
"float64",
"\n... | // Variance computes the variance of the buffer. | [
"Variance",
"computes",
"the",
"variance",
"of",
"the",
"buffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L197-L210 | train |
wcharczuk/go-chart | seq/seq.go | StdDev | func (s Seq) StdDev() float64 {
if s.Len() == 0 {
return 0
}
return math.Pow(s.Variance(), 0.5)
} | go | func (s Seq) StdDev() float64 {
if s.Len() == 0 {
return 0
}
return math.Pow(s.Variance(), 0.5)
} | [
"func",
"(",
"s",
"Seq",
")",
"StdDev",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"return",
"math",
".",
"Pow",
"(",
"s",
".",
"Variance",
"(",
")",
",",
"0.5",
")",
"\n",
"... | // StdDev returns the standard deviation. | [
"StdDev",
"returns",
"the",
"standard",
"deviation",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L213-L219 | train |
wcharczuk/go-chart | seq/seq.go | Percentile | func (s Seq) Percentile(percent float64) (percentile float64) {
l := s.Len()
if l == 0 {
return 0
}
if percent < 0 || percent > 1.0 {
panic("percent out of range [0.0, 1.0)")
}
sorted := s.Sort()
index := percent * float64(l)
if index == float64(int64(index)) {
i := f64i(index)
ci := sorted.GetValue(i - 1)
c := sorted.GetValue(i)
percentile = (ci + c) / 2.0
} else {
i := f64i(index)
percentile = sorted.GetValue(i)
}
return percentile
} | go | func (s Seq) Percentile(percent float64) (percentile float64) {
l := s.Len()
if l == 0 {
return 0
}
if percent < 0 || percent > 1.0 {
panic("percent out of range [0.0, 1.0)")
}
sorted := s.Sort()
index := percent * float64(l)
if index == float64(int64(index)) {
i := f64i(index)
ci := sorted.GetValue(i - 1)
c := sorted.GetValue(i)
percentile = (ci + c) / 2.0
} else {
i := f64i(index)
percentile = sorted.GetValue(i)
}
return percentile
} | [
"func",
"(",
"s",
"Seq",
")",
"Percentile",
"(",
"percent",
"float64",
")",
"(",
"percentile",
"float64",
")",
"{",
"l",
":=",
"s",
".",
"Len",
"(",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"if",
"percent",
"<",
"... | //Percentile finds the relative standing in a slice of floats.
// `percent` should be given on the interval [0,1.0). | [
"Percentile",
"finds",
"the",
"relative",
"standing",
"in",
"a",
"slice",
"of",
"floats",
".",
"percent",
"should",
"be",
"given",
"on",
"the",
"interval",
"[",
"0",
"1",
".",
"0",
")",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L223-L246 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.