id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1 value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
19,100 | francoispqt/gojay | encode_number_int.go | AddInt64KeyNullEmpty | func (enc *Encoder) AddInt64KeyNullEmpty(key string, v int64) {
enc.Int64KeyNullEmpty(key, v)
} | go | func (enc *Encoder) AddInt64KeyNullEmpty(key string, v int64) {
enc.Int64KeyNullEmpty(key, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddInt64KeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"int64",
")",
"{",
"enc",
".",
"Int64KeyNullEmpty",
"(",
"key",
",",
"v",
")",
"\n",
"}"
] | // AddInt64KeyNullEmpty adds an int64 to be encoded and skips it if its value is 0.
// Must be used inside an object as it will encode a key. | [
"AddInt64KeyNullEmpty",
"adds",
"an",
"int64",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"its",
"value",
"is",
"0",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L248-L250 |
19,101 | francoispqt/gojay | encode_number_int.go | AddInt32Key | func (enc *Encoder) AddInt32Key(key string, v int32) {
enc.Int64Key(key, int64(v))
} | go | func (enc *Encoder) AddInt32Key(key string, v int32) {
enc.Int64Key(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddInt32Key",
"(",
"key",
"string",
",",
"v",
"int32",
")",
"{",
"enc",
".",
"Int64Key",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // AddInt32Key adds an int32 to be encoded, must be used inside an object as it will encode a key | [
"AddInt32Key",
"adds",
"an",
"int32",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L345-L347 |
19,102 | francoispqt/gojay | encode_number_int.go | AddInt32KeyOmitEmpty | func (enc *Encoder) AddInt32KeyOmitEmpty(key string, v int32) {
enc.Int64KeyOmitEmpty(key, int64(v))
} | go | func (enc *Encoder) AddInt32KeyOmitEmpty(key string, v int32) {
enc.Int64KeyOmitEmpty(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddInt32KeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"int32",
")",
"{",
"enc",
".",
"Int64KeyOmitEmpty",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // AddInt32KeyOmitEmpty adds an int32 to be encoded and skips it if its value is 0.
// Must be used inside an object as it will encode a key. | [
"AddInt32KeyOmitEmpty",
"adds",
"an",
"int32",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"its",
"value",
"is",
"0",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L351-L353 |
19,103 | francoispqt/gojay | encode_number_int.go | Int32KeyNullEmpty | func (enc *Encoder) Int32KeyNullEmpty(key string, v int32) {
enc.Int64KeyNullEmpty(key, int64(v))
} | go | func (enc *Encoder) Int32KeyNullEmpty(key string, v int32) {
enc.Int64KeyNullEmpty(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"Int32KeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"int32",
")",
"{",
"enc",
".",
"Int64KeyNullEmpty",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // Int32KeyNullEmpty adds an int32 to be encoded and skips it if its value is 0.
// Must be used inside an object as it will encode a key. | [
"Int32KeyNullEmpty",
"adds",
"an",
"int32",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"its",
"value",
"is",
"0",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L368-L370 |
19,104 | francoispqt/gojay | encode_number_int.go | AddInt16Key | func (enc *Encoder) AddInt16Key(key string, v int16) {
enc.Int64Key(key, int64(v))
} | go | func (enc *Encoder) AddInt16Key(key string, v int16) {
enc.Int64Key(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddInt16Key",
"(",
"key",
"string",
",",
"v",
"int16",
")",
"{",
"enc",
".",
"Int64Key",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // AddInt16Key adds an int16 to be encoded, must be used inside an object as it will encode a key | [
"AddInt16Key",
"adds",
"an",
"int16",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L401-L403 |
19,105 | francoispqt/gojay | encode_number_int.go | AddInt16KeyOmitEmpty | func (enc *Encoder) AddInt16KeyOmitEmpty(key string, v int16) {
enc.Int64KeyOmitEmpty(key, int64(v))
} | go | func (enc *Encoder) AddInt16KeyOmitEmpty(key string, v int16) {
enc.Int64KeyOmitEmpty(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddInt16KeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"int16",
")",
"{",
"enc",
".",
"Int64KeyOmitEmpty",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // AddInt16KeyOmitEmpty adds an int16 to be encoded and skips it if its value is 0.
// Must be used inside an object as it will encode a key. | [
"AddInt16KeyOmitEmpty",
"adds",
"an",
"int16",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"its",
"value",
"is",
"0",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L407-L409 |
19,106 | francoispqt/gojay | encode_number_int.go | Int16KeyNullEmpty | func (enc *Encoder) Int16KeyNullEmpty(key string, v int16) {
enc.Int64KeyNullEmpty(key, int64(v))
} | go | func (enc *Encoder) Int16KeyNullEmpty(key string, v int16) {
enc.Int64KeyNullEmpty(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"Int16KeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"int16",
")",
"{",
"enc",
".",
"Int64KeyNullEmpty",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // Int16KeyNullEmpty adds an int16 to be encoded and skips it if its value is 0.
// Must be used inside an object as it will encode a key. | [
"Int16KeyNullEmpty",
"adds",
"an",
"int16",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"its",
"value",
"is",
"0",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L430-L432 |
19,107 | francoispqt/gojay | encode_number_int.go | AddInt8KeyOmitEmpty | func (enc *Encoder) AddInt8KeyOmitEmpty(key string, v int8) {
enc.Int64KeyOmitEmpty(key, int64(v))
} | go | func (enc *Encoder) AddInt8KeyOmitEmpty(key string, v int8) {
enc.Int64KeyOmitEmpty(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddInt8KeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"int8",
")",
"{",
"enc",
".",
"Int64KeyOmitEmpty",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // AddInt8KeyOmitEmpty adds an int8 to be encoded and skips it if its value is 0.
// Must be used inside an object as it will encode a key. | [
"AddInt8KeyOmitEmpty",
"adds",
"an",
"int8",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"its",
"value",
"is",
"0",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L475-L477 |
19,108 | francoispqt/gojay | encode_number_int.go | AddInt8KeyNullEmpty | func (enc *Encoder) AddInt8KeyNullEmpty(key string, v int8) {
enc.Int64KeyNullEmpty(key, int64(v))
} | go | func (enc *Encoder) AddInt8KeyNullEmpty(key string, v int8) {
enc.Int64KeyNullEmpty(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddInt8KeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"int8",
")",
"{",
"enc",
".",
"Int64KeyNullEmpty",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // AddInt8KeyNullEmpty adds an int8 to be encoded and skips it if its value is 0.
// Must be used inside an object as it will encode a key. | [
"AddInt8KeyNullEmpty",
"adds",
"an",
"int8",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"its",
"value",
"is",
"0",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L481-L483 |
19,109 | francoispqt/gojay | encode_number_int.go | Int8Key | func (enc *Encoder) Int8Key(key string, v int8) {
enc.Int64Key(key, int64(v))
} | go | func (enc *Encoder) Int8Key(key string, v int8) {
enc.Int64Key(key, int64(v))
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"Int8Key",
"(",
"key",
"string",
",",
"v",
"int8",
")",
"{",
"enc",
".",
"Int64Key",
"(",
"key",
",",
"int64",
"(",
"v",
")",
")",
"\n",
"}"
] | // Int8Key adds an int8 to be encoded, must be used inside an object as it will encode a key | [
"Int8Key",
"adds",
"an",
"int8",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_number_int.go#L486-L488 |
19,110 | francoispqt/gojay | encode_bool.go | EncodeBool | func (enc *Encoder) EncodeBool(v bool) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeBool(v)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | go | func (enc *Encoder) EncodeBool(v bool) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeBool(v)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeBool",
"(",
"v",
"bool",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"_",
",",
"_",
"="... | // EncodeBool encodes a bool to JSON | [
"EncodeBool",
"encodes",
"a",
"bool",
"to",
"JSON"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_bool.go#L6-L17 |
19,111 | francoispqt/gojay | encode_bool.go | encodeBool | func (enc *Encoder) encodeBool(v bool) ([]byte, error) {
enc.grow(5)
if v {
enc.writeString("true")
} else {
enc.writeString("false")
}
return enc.buf, enc.err
} | go | func (enc *Encoder) encodeBool(v bool) ([]byte, error) {
enc.grow(5)
if v {
enc.writeString("true")
} else {
enc.writeString("false")
}
return enc.buf, enc.err
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"encodeBool",
"(",
"v",
"bool",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"enc",
".",
"grow",
"(",
"5",
")",
"\n",
"if",
"v",
"{",
"enc",
".",
"writeString",
"(",
"\"",
"\"",
")",
"\n",
"}",
... | // encodeBool encodes a bool to JSON | [
"encodeBool",
"encodes",
"a",
"bool",
"to",
"JSON"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_bool.go#L20-L28 |
19,112 | francoispqt/gojay | encode_bool.go | AddBoolKey | func (enc *Encoder) AddBoolKey(key string, v bool) {
enc.BoolKey(key, v)
} | go | func (enc *Encoder) AddBoolKey(key string, v bool) {
enc.BoolKey(key, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddBoolKey",
"(",
"key",
"string",
",",
"v",
"bool",
")",
"{",
"enc",
".",
"BoolKey",
"(",
"key",
",",
"v",
")",
"\n",
"}"
] | // AddBoolKey adds a bool to be encoded, must be used inside an object as it will encode a key. | [
"AddBoolKey",
"adds",
"a",
"bool",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_bool.go#L46-L48 |
19,113 | francoispqt/gojay | encode_bool.go | AddBoolKeyOmitEmpty | func (enc *Encoder) AddBoolKeyOmitEmpty(key string, v bool) {
enc.BoolKeyOmitEmpty(key, v)
} | go | func (enc *Encoder) AddBoolKeyOmitEmpty(key string, v bool) {
enc.BoolKeyOmitEmpty(key, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddBoolKeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"bool",
")",
"{",
"enc",
".",
"BoolKeyOmitEmpty",
"(",
"key",
",",
"v",
")",
"\n",
"}"
] | // AddBoolKeyOmitEmpty adds a bool to be encoded and skips if it is zero value.
// Must be used inside an object as it will encode a key. | [
"AddBoolKeyOmitEmpty",
"adds",
"a",
"bool",
"to",
"be",
"encoded",
"and",
"skips",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_bool.go#L52-L54 |
19,114 | francoispqt/gojay | encode_bool.go | AddBoolKeyNullEmpty | func (enc *Encoder) AddBoolKeyNullEmpty(key string, v bool) {
enc.BoolKeyNullEmpty(key, v)
} | go | func (enc *Encoder) AddBoolKeyNullEmpty(key string, v bool) {
enc.BoolKeyNullEmpty(key, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddBoolKeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"bool",
")",
"{",
"enc",
".",
"BoolKeyNullEmpty",
"(",
"key",
",",
"v",
")",
"\n",
"}"
] | // AddBoolKeyNullEmpty adds a bool to be encoded and encodes `null` if it is zero value.
// Must be used inside an object as it will encode a key. | [
"AddBoolKeyNullEmpty",
"adds",
"a",
"bool",
"to",
"be",
"encoded",
"and",
"encodes",
"null",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_bool.go#L58-L60 |
19,115 | francoispqt/gojay | encode_bool.go | BoolKey | func (enc *Encoder) BoolKey(key string, value bool) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKey)
enc.buf = strconv.AppendBool(enc.buf, value)
} | go | func (enc *Encoder) BoolKey(key string, value bool) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKey)
enc.buf = strconv.AppendBool(enc.buf, value)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"BoolKey",
"(",
"key",
"string",
",",
"value",
"bool",
")",
"{",
"if",
"enc",
".",
"hasKeys",
"{",
"if",
"!",
"enc",
".",
"keyExists",
"(",
"key",
")",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"enc",
"... | // BoolKey adds a bool to be encoded, must be used inside an object as it will encode a key. | [
"BoolKey",
"adds",
"a",
"bool",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_bool.go#L104-L119 |
19,116 | francoispqt/gojay | encode_bool.go | BoolKeyOmitEmpty | func (enc *Encoder) BoolKeyOmitEmpty(key string, v bool) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if v == false {
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKey)
enc.buf = strconv.AppendBool(enc.buf, v)
} | go | func (enc *Encoder) BoolKeyOmitEmpty(key string, v bool) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if v == false {
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKey)
enc.buf = strconv.AppendBool(enc.buf, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"BoolKeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"bool",
")",
"{",
"if",
"enc",
".",
"hasKeys",
"{",
"if",
"!",
"enc",
".",
"keyExists",
"(",
"key",
")",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"if",... | // BoolKeyOmitEmpty adds a bool to be encoded and skips it if it is zero value.
// Must be used inside an object as it will encode a key. | [
"BoolKeyOmitEmpty",
"adds",
"a",
"bool",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_bool.go#L123-L141 |
19,117 | francoispqt/gojay | encode_stream.go | EncodeStream | func (s *StreamEncoder) EncodeStream(m MarshalerStream) {
// if a single consumer, just use this encoder
if s.nConsumer == 1 {
go consume(s, s, m)
return
}
// else use this Encoder only for first consumer
// and use new encoders for other consumers
// this is to avoid concurrent writing to same buffer
// resulting in a weird JSON
go consume(s, s, m)
for i := 1; i < s.nConsumer; i++ {
s.mux.RLock()
select {
case <-s.done:
default:
ss := Stream.borrowEncoder(s.w)
ss.mux.Lock()
ss.done = s.done
ss.buf = make([]byte, 0, 512)
ss.delimiter = s.delimiter
go consume(s, ss, m)
ss.mux.Unlock()
}
s.mux.RUnlock()
}
return
} | go | func (s *StreamEncoder) EncodeStream(m MarshalerStream) {
// if a single consumer, just use this encoder
if s.nConsumer == 1 {
go consume(s, s, m)
return
}
// else use this Encoder only for first consumer
// and use new encoders for other consumers
// this is to avoid concurrent writing to same buffer
// resulting in a weird JSON
go consume(s, s, m)
for i := 1; i < s.nConsumer; i++ {
s.mux.RLock()
select {
case <-s.done:
default:
ss := Stream.borrowEncoder(s.w)
ss.mux.Lock()
ss.done = s.done
ss.buf = make([]byte, 0, 512)
ss.delimiter = s.delimiter
go consume(s, ss, m)
ss.mux.Unlock()
}
s.mux.RUnlock()
}
return
} | [
"func",
"(",
"s",
"*",
"StreamEncoder",
")",
"EncodeStream",
"(",
"m",
"MarshalerStream",
")",
"{",
"// if a single consumer, just use this encoder",
"if",
"s",
".",
"nConsumer",
"==",
"1",
"{",
"go",
"consume",
"(",
"s",
",",
"s",
",",
"m",
")",
"\n",
"re... | // EncodeStream spins up a defined number of non blocking consumers of the MarshalerStream m.
//
// m must implement MarshalerStream. Ideally m is a channel. See example for implementation.
//
// See the documentation for Marshal for details about the conversion of Go value to JSON. | [
"EncodeStream",
"spins",
"up",
"a",
"defined",
"number",
"of",
"non",
"blocking",
"consumers",
"of",
"the",
"MarshalerStream",
"m",
".",
"m",
"must",
"implement",
"MarshalerStream",
".",
"Ideally",
"m",
"is",
"a",
"channel",
".",
"See",
"example",
"for",
"im... | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_stream.go#L32-L59 |
19,118 | francoispqt/gojay | encode_stream.go | NConsumer | func (s *StreamEncoder) NConsumer(n int) *StreamEncoder {
s.nConsumer = n
return s
} | go | func (s *StreamEncoder) NConsumer(n int) *StreamEncoder {
s.nConsumer = n
return s
} | [
"func",
"(",
"s",
"*",
"StreamEncoder",
")",
"NConsumer",
"(",
"n",
"int",
")",
"*",
"StreamEncoder",
"{",
"s",
".",
"nConsumer",
"=",
"n",
"\n",
"return",
"s",
"\n",
"}"
] | // NConsumer sets the number of non blocking go routine to consume the stream. | [
"NConsumer",
"sets",
"the",
"number",
"of",
"non",
"blocking",
"go",
"routine",
"to",
"consume",
"the",
"stream",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_stream.go#L78-L81 |
19,119 | francoispqt/gojay | encode_stream.go | AddObject | func (s *StreamEncoder) AddObject(v MarshalerJSONObject) {
if v.IsNil() {
return
}
s.Encoder.writeByte('{')
v.MarshalJSONObject(s.Encoder)
s.Encoder.writeByte('}')
s.Encoder.writeByte(s.delimiter)
} | go | func (s *StreamEncoder) AddObject(v MarshalerJSONObject) {
if v.IsNil() {
return
}
s.Encoder.writeByte('{')
v.MarshalJSONObject(s.Encoder)
s.Encoder.writeByte('}')
s.Encoder.writeByte(s.delimiter)
} | [
"func",
"(",
"s",
"*",
"StreamEncoder",
")",
"AddObject",
"(",
"v",
"MarshalerJSONObject",
")",
"{",
"if",
"v",
".",
"IsNil",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"s",
".",
"Encoder",
".",
"writeByte",
"(",
"'{'",
")",
"\n",
"v",
".",
"Marshal... | // AddObject adds an object to be encoded.
// value must implement MarshalerJSONObject. | [
"AddObject",
"adds",
"an",
"object",
"to",
"be",
"encoded",
".",
"value",
"must",
"implement",
"MarshalerJSONObject",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_stream.go#L141-L149 |
19,120 | francoispqt/gojay | encode_stream.go | AddString | func (s *StreamEncoder) AddString(v string) {
s.Encoder.writeByte('"')
s.Encoder.writeString(v)
s.Encoder.writeByte('"')
s.Encoder.writeByte(s.delimiter)
} | go | func (s *StreamEncoder) AddString(v string) {
s.Encoder.writeByte('"')
s.Encoder.writeString(v)
s.Encoder.writeByte('"')
s.Encoder.writeByte(s.delimiter)
} | [
"func",
"(",
"s",
"*",
"StreamEncoder",
")",
"AddString",
"(",
"v",
"string",
")",
"{",
"s",
".",
"Encoder",
".",
"writeByte",
"(",
"'\"'",
")",
"\n",
"s",
".",
"Encoder",
".",
"writeString",
"(",
"v",
")",
"\n",
"s",
".",
"Encoder",
".",
"writeByt... | // AddString adds a string to be encoded. | [
"AddString",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_stream.go#L152-L157 |
19,121 | francoispqt/gojay | encode_stream.go | AddArray | func (s *StreamEncoder) AddArray(v MarshalerJSONArray) {
s.Encoder.writeByte('[')
v.MarshalJSONArray(s.Encoder)
s.Encoder.writeByte(']')
s.Encoder.writeByte(s.delimiter)
} | go | func (s *StreamEncoder) AddArray(v MarshalerJSONArray) {
s.Encoder.writeByte('[')
v.MarshalJSONArray(s.Encoder)
s.Encoder.writeByte(']')
s.Encoder.writeByte(s.delimiter)
} | [
"func",
"(",
"s",
"*",
"StreamEncoder",
")",
"AddArray",
"(",
"v",
"MarshalerJSONArray",
")",
"{",
"s",
".",
"Encoder",
".",
"writeByte",
"(",
"'['",
")",
"\n",
"v",
".",
"MarshalJSONArray",
"(",
"s",
".",
"Encoder",
")",
"\n",
"s",
".",
"Encoder",
"... | // AddArray adds an implementation of MarshalerJSONArray to be encoded. | [
"AddArray",
"adds",
"an",
"implementation",
"of",
"MarshalerJSONArray",
"to",
"be",
"encoded",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_stream.go#L160-L165 |
19,122 | francoispqt/gojay | encode_stream.go | AddInt | func (s *StreamEncoder) AddInt(value int) {
s.buf = strconv.AppendInt(s.buf, int64(value), 10)
s.Encoder.writeByte(s.delimiter)
} | go | func (s *StreamEncoder) AddInt(value int) {
s.buf = strconv.AppendInt(s.buf, int64(value), 10)
s.Encoder.writeByte(s.delimiter)
} | [
"func",
"(",
"s",
"*",
"StreamEncoder",
")",
"AddInt",
"(",
"value",
"int",
")",
"{",
"s",
".",
"buf",
"=",
"strconv",
".",
"AppendInt",
"(",
"s",
".",
"buf",
",",
"int64",
"(",
"value",
")",
",",
"10",
")",
"\n",
"s",
".",
"Encoder",
".",
"wri... | // AddInt adds an int to be encoded. | [
"AddInt",
"adds",
"an",
"int",
"to",
"be",
"encoded",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_stream.go#L168-L171 |
19,123 | francoispqt/gojay | encode_stream.go | AddFloat64 | func (s *StreamEncoder) AddFloat64(value float64) {
s.buf = strconv.AppendFloat(s.buf, value, 'f', -1, 64)
s.Encoder.writeByte(s.delimiter)
} | go | func (s *StreamEncoder) AddFloat64(value float64) {
s.buf = strconv.AppendFloat(s.buf, value, 'f', -1, 64)
s.Encoder.writeByte(s.delimiter)
} | [
"func",
"(",
"s",
"*",
"StreamEncoder",
")",
"AddFloat64",
"(",
"value",
"float64",
")",
"{",
"s",
".",
"buf",
"=",
"strconv",
".",
"AppendFloat",
"(",
"s",
".",
"buf",
",",
"value",
",",
"'f'",
",",
"-",
"1",
",",
"64",
")",
"\n",
"s",
".",
"E... | // AddFloat64 adds a float64 to be encoded. | [
"AddFloat64",
"adds",
"a",
"float64",
"to",
"be",
"encoded",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_stream.go#L174-L177 |
19,124 | francoispqt/gojay | examples/fuzz/main.go | UnmarshalJSONObject | func (u *user) UnmarshalJSONObject(dec *gojay.Decoder, key string) error {
switch key {
case "id":
return dec.Int(&u.id)
case "created":
return dec.Uint64(&u.created)
case "age":
return dec.Float(&u.age)
case "name":
return dec.String(&u.name)
case "email":
return dec.String(&u.email)
case "friend":
uu := &user{}
return dec.Object(uu)
}
return nil
} | go | func (u *user) UnmarshalJSONObject(dec *gojay.Decoder, key string) error {
switch key {
case "id":
return dec.Int(&u.id)
case "created":
return dec.Uint64(&u.created)
case "age":
return dec.Float(&u.age)
case "name":
return dec.String(&u.name)
case "email":
return dec.String(&u.email)
case "friend":
uu := &user{}
return dec.Object(uu)
}
return nil
} | [
"func",
"(",
"u",
"*",
"user",
")",
"UnmarshalJSONObject",
"(",
"dec",
"*",
"gojay",
".",
"Decoder",
",",
"key",
"string",
")",
"error",
"{",
"switch",
"key",
"{",
"case",
"\"",
"\"",
":",
"return",
"dec",
".",
"Int",
"(",
"&",
"u",
".",
"id",
")... | // implement gojay.UnmarshalerJSONObject | [
"implement",
"gojay",
".",
"UnmarshalerJSONObject"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/examples/fuzz/main.go#L17-L34 |
19,125 | francoispqt/gojay | decode_pool.go | NewDecoder | func NewDecoder(r io.Reader) *Decoder {
return &Decoder{
called: 0,
cursor: 0,
keysDone: 0,
err: nil,
r: r,
data: make([]byte, 512),
length: 0,
isPooled: 0,
}
} | go | func NewDecoder(r io.Reader) *Decoder {
return &Decoder{
called: 0,
cursor: 0,
keysDone: 0,
err: nil,
r: r,
data: make([]byte, 512),
length: 0,
isPooled: 0,
}
} | [
"func",
"NewDecoder",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Decoder",
"{",
"return",
"&",
"Decoder",
"{",
"called",
":",
"0",
",",
"cursor",
":",
"0",
",",
"keysDone",
":",
"0",
",",
"err",
":",
"nil",
",",
"r",
":",
"r",
",",
"data",
":",
... | // NewDecoder returns a new decoder.
// It takes an io.Reader implementation as data input. | [
"NewDecoder",
"returns",
"a",
"new",
"decoder",
".",
"It",
"takes",
"an",
"io",
".",
"Reader",
"implementation",
"as",
"data",
"input",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/decode_pool.go#L20-L31 |
19,126 | francoispqt/gojay | encode_embedded_json.go | AddEmbeddedJSON | func (enc *Encoder) AddEmbeddedJSON(v *EmbeddedJSON) {
enc.grow(len(*v) + 4)
r := enc.getPreviousRune()
if r != '[' {
enc.writeByte(',')
}
enc.writeBytes(*v)
} | go | func (enc *Encoder) AddEmbeddedJSON(v *EmbeddedJSON) {
enc.grow(len(*v) + 4)
r := enc.getPreviousRune()
if r != '[' {
enc.writeByte(',')
}
enc.writeBytes(*v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddEmbeddedJSON",
"(",
"v",
"*",
"EmbeddedJSON",
")",
"{",
"enc",
".",
"grow",
"(",
"len",
"(",
"*",
"v",
")",
"+",
"4",
")",
"\n",
"r",
":=",
"enc",
".",
"getPreviousRune",
"(",
")",
"\n",
"if",
"r",
"... | // AddEmbeddedJSON adds an EmbeddedJSON to be encoded.
//
// It basically blindly writes the bytes to the final buffer. Therefore,
// it expects the JSON to be of proper format. | [
"AddEmbeddedJSON",
"adds",
"an",
"EmbeddedJSON",
"to",
"be",
"encoded",
".",
"It",
"basically",
"blindly",
"writes",
"the",
"bytes",
"to",
"the",
"final",
"buffer",
".",
"Therefore",
"it",
"expects",
"the",
"JSON",
"to",
"be",
"of",
"proper",
"format",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_embedded_json.go#L26-L33 |
19,127 | francoispqt/gojay | encode_embedded_json.go | AddEmbeddedJSONOmitEmpty | func (enc *Encoder) AddEmbeddedJSONOmitEmpty(v *EmbeddedJSON) {
if v == nil || len(*v) == 0 {
return
}
r := enc.getPreviousRune()
if r != '[' {
enc.writeByte(',')
}
enc.writeBytes(*v)
} | go | func (enc *Encoder) AddEmbeddedJSONOmitEmpty(v *EmbeddedJSON) {
if v == nil || len(*v) == 0 {
return
}
r := enc.getPreviousRune()
if r != '[' {
enc.writeByte(',')
}
enc.writeBytes(*v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddEmbeddedJSONOmitEmpty",
"(",
"v",
"*",
"EmbeddedJSON",
")",
"{",
"if",
"v",
"==",
"nil",
"||",
"len",
"(",
"*",
"v",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"r",
":=",
"enc",
".",
"getPreviousRun... | // AddEmbeddedJSONOmitEmpty adds an EmbeddedJSON to be encoded or skips it if nil pointer or empty.
//
// It basically blindly writes the bytes to the final buffer. Therefore,
// it expects the JSON to be of proper format. | [
"AddEmbeddedJSONOmitEmpty",
"adds",
"an",
"EmbeddedJSON",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"nil",
"pointer",
"or",
"empty",
".",
"It",
"basically",
"blindly",
"writes",
"the",
"bytes",
"to",
"the",
"final",
"buffer",
".",
"Therefore",
"it",
... | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_embedded_json.go#L39-L48 |
19,128 | francoispqt/gojay | encode_embedded_json.go | AddEmbeddedJSONKey | func (enc *Encoder) AddEmbeddedJSONKey(key string, v *EmbeddedJSON) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
enc.grow(len(key) + len(*v) + 5)
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKey)
enc.writeBytes(*v)
} | go | func (enc *Encoder) AddEmbeddedJSONKey(key string, v *EmbeddedJSON) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
enc.grow(len(key) + len(*v) + 5)
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKey)
enc.writeBytes(*v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddEmbeddedJSONKey",
"(",
"key",
"string",
",",
"v",
"*",
"EmbeddedJSON",
")",
"{",
"if",
"enc",
".",
"hasKeys",
"{",
"if",
"!",
"enc",
".",
"keyExists",
"(",
"key",
")",
"{",
"return",
"\n",
"}",
"\n",
"}"... | // AddEmbeddedJSONKey adds an EmbeddedJSON and a key to be encoded.
//
// It basically blindly writes the bytes to the final buffer. Therefore,
// it expects the JSON to be of proper format. | [
"AddEmbeddedJSONKey",
"adds",
"an",
"EmbeddedJSON",
"and",
"a",
"key",
"to",
"be",
"encoded",
".",
"It",
"basically",
"blindly",
"writes",
"the",
"bytes",
"to",
"the",
"final",
"buffer",
".",
"Therefore",
"it",
"expects",
"the",
"JSON",
"to",
"be",
"of",
"... | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_embedded_json.go#L54-L69 |
19,129 | francoispqt/gojay | encode_array.go | EncodeArray | func (enc *Encoder) EncodeArray(v MarshalerJSONArray) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeArray(v)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | go | func (enc *Encoder) EncodeArray(v MarshalerJSONArray) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeArray(v)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeArray",
"(",
"v",
"MarshalerJSONArray",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"_",
",... | // EncodeArray encodes an implementation of MarshalerJSONArray to JSON | [
"EncodeArray",
"encodes",
"an",
"implementation",
"of",
"MarshalerJSONArray",
"to",
"JSON"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_array.go#L4-L15 |
19,130 | francoispqt/gojay | encode_array.go | AddArrayKey | func (enc *Encoder) AddArrayKey(key string, v MarshalerJSONArray) {
enc.ArrayKey(key, v)
} | go | func (enc *Encoder) AddArrayKey(key string, v MarshalerJSONArray) {
enc.ArrayKey(key, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddArrayKey",
"(",
"key",
"string",
",",
"v",
"MarshalerJSONArray",
")",
"{",
"enc",
".",
"ArrayKey",
"(",
"key",
",",
"v",
")",
"\n",
"}"
] | // AddArrayKey adds an array or slice to be encoded, must be used inside an object as it will encode a key
// value must implement Marshaler | [
"AddArrayKey",
"adds",
"an",
"array",
"or",
"slice",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"value",
"must",
"implement",
"Marshaler"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_array.go#L44-L46 |
19,131 | francoispqt/gojay | encode_array.go | AddArrayKeyOmitEmpty | func (enc *Encoder) AddArrayKeyOmitEmpty(key string, v MarshalerJSONArray) {
enc.ArrayKeyOmitEmpty(key, v)
} | go | func (enc *Encoder) AddArrayKeyOmitEmpty(key string, v MarshalerJSONArray) {
enc.ArrayKeyOmitEmpty(key, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddArrayKeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"MarshalerJSONArray",
")",
"{",
"enc",
".",
"ArrayKeyOmitEmpty",
"(",
"key",
",",
"v",
")",
"\n",
"}"
] | // AddArrayKeyOmitEmpty adds an array or slice to be encoded and skips it if it is nil.
// Must be called inside an object as it will encode a key. | [
"AddArrayKeyOmitEmpty",
"adds",
"an",
"array",
"or",
"slice",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"it",
"is",
"nil",
".",
"Must",
"be",
"called",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_array.go#L50-L52 |
19,132 | francoispqt/gojay | encode_array.go | AddArrayKeyNullEmpty | func (enc *Encoder) AddArrayKeyNullEmpty(key string, v MarshalerJSONArray) {
enc.ArrayKeyNullEmpty(key, v)
} | go | func (enc *Encoder) AddArrayKeyNullEmpty(key string, v MarshalerJSONArray) {
enc.ArrayKeyNullEmpty(key, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddArrayKeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"MarshalerJSONArray",
")",
"{",
"enc",
".",
"ArrayKeyNullEmpty",
"(",
"key",
",",
"v",
")",
"\n",
"}"
] | // AddArrayKeyNullEmpty adds an array or slice to be encoded and skips it if it is nil.
// Must be called inside an object as it will encode a key. `null` will be encoded` | [
"AddArrayKeyNullEmpty",
"adds",
"an",
"array",
"or",
"slice",
"to",
"be",
"encoded",
"and",
"skips",
"it",
"if",
"it",
"is",
"nil",
".",
"Must",
"be",
"called",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
".",
"null",
"will",
"b... | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_array.go#L56-L58 |
19,133 | francoispqt/gojay | encode_array.go | ArrayKey | func (enc *Encoder) ArrayKey(key string, v MarshalerJSONArray) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if v.IsNil() {
enc.grow(2 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyArr)
enc.writeByte(']')
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyArr)
v.MarshalJSONArray(enc)
enc.writeByte(']')
} | go | func (enc *Encoder) ArrayKey(key string, v MarshalerJSONArray) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if v.IsNil() {
enc.grow(2 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyArr)
enc.writeByte(']')
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyArr)
v.MarshalJSONArray(enc)
enc.writeByte(']')
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"ArrayKey",
"(",
"key",
"string",
",",
"v",
"MarshalerJSONArray",
")",
"{",
"if",
"enc",
".",
"hasKeys",
"{",
"if",
"!",
"enc",
".",
"keyExists",
"(",
"key",
")",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
... | // ArrayKey adds an array or slice to be encoded, must be used inside an object as it will encode a key
// value must implement Marshaler | [
"ArrayKey",
"adds",
"an",
"array",
"or",
"slice",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"value",
"must",
"implement",
"Marshaler"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_array.go#L118-L146 |
19,134 | francoispqt/gojay | encode_array.go | ArrayKeyOmitEmpty | func (enc *Encoder) ArrayKeyOmitEmpty(key string, v MarshalerJSONArray) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if v.IsNil() {
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyArr)
v.MarshalJSONArray(enc)
enc.writeByte(']')
} | go | func (enc *Encoder) ArrayKeyOmitEmpty(key string, v MarshalerJSONArray) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if v.IsNil() {
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyArr)
v.MarshalJSONArray(enc)
enc.writeByte(']')
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"ArrayKeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"MarshalerJSONArray",
")",
"{",
"if",
"enc",
".",
"hasKeys",
"{",
"if",
"!",
"enc",
".",
"keyExists",
"(",
"key",
")",
"{",
"return",
"\n",
"}",
"\n",
"}",
... | // ArrayKeyOmitEmpty adds an array or slice to be encoded and skips if it is nil.
// Must be called inside an object as it will encode a key. | [
"ArrayKeyOmitEmpty",
"adds",
"an",
"array",
"or",
"slice",
"to",
"be",
"encoded",
"and",
"skips",
"if",
"it",
"is",
"nil",
".",
"Must",
"be",
"called",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_array.go#L150-L169 |
19,135 | francoispqt/gojay | decode_embedded_json.go | EmbeddedJSON | func (dec *Decoder) EmbeddedJSON(v *EmbeddedJSON) error {
err := dec.decodeEmbeddedJSON(v)
if err != nil {
return err
}
dec.called |= 1
return nil
} | go | func (dec *Decoder) EmbeddedJSON(v *EmbeddedJSON) error {
err := dec.decodeEmbeddedJSON(v)
if err != nil {
return err
}
dec.called |= 1
return nil
} | [
"func",
"(",
"dec",
"*",
"Decoder",
")",
"EmbeddedJSON",
"(",
"v",
"*",
"EmbeddedJSON",
")",
"error",
"{",
"err",
":=",
"dec",
".",
"decodeEmbeddedJSON",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"dec",
"... | // EmbeddedJSON adds an EmbeddedsJSON to the value pointed by v.
// It can be used to delay JSON decoding or precompute a JSON encoding. | [
"EmbeddedJSON",
"adds",
"an",
"EmbeddedsJSON",
"to",
"the",
"value",
"pointed",
"by",
"v",
".",
"It",
"can",
"be",
"used",
"to",
"delay",
"JSON",
"decoding",
"or",
"precompute",
"a",
"JSON",
"encoding",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/decode_embedded_json.go#L78-L85 |
19,136 | francoispqt/gojay | encode_interface.go | Encode | func (enc *Encoder) Encode(v interface{}) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
switch vt := v.(type) {
case string:
return enc.EncodeString(vt)
case bool:
return enc.EncodeBool(vt)
case MarshalerJSONArray:
return enc.EncodeArray(vt)
case MarshalerJSONObject:
return enc.EncodeObject(vt)
case int:
return enc.EncodeInt(vt)
case int64:
return enc.EncodeInt64(vt)
case int32:
return enc.EncodeInt(int(vt))
case int8:
return enc.EncodeInt(int(vt))
case uint64:
return enc.EncodeUint64(vt)
case uint32:
return enc.EncodeInt(int(vt))
case uint16:
return enc.EncodeInt(int(vt))
case uint8:
return enc.EncodeInt(int(vt))
case float64:
return enc.EncodeFloat(vt)
case float32:
return enc.EncodeFloat32(vt)
case *EmbeddedJSON:
return enc.EncodeEmbeddedJSON(vt)
default:
return InvalidMarshalError(fmt.Sprintf(invalidMarshalErrorMsg, vt))
}
} | go | func (enc *Encoder) Encode(v interface{}) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
switch vt := v.(type) {
case string:
return enc.EncodeString(vt)
case bool:
return enc.EncodeBool(vt)
case MarshalerJSONArray:
return enc.EncodeArray(vt)
case MarshalerJSONObject:
return enc.EncodeObject(vt)
case int:
return enc.EncodeInt(vt)
case int64:
return enc.EncodeInt64(vt)
case int32:
return enc.EncodeInt(int(vt))
case int8:
return enc.EncodeInt(int(vt))
case uint64:
return enc.EncodeUint64(vt)
case uint32:
return enc.EncodeInt(int(vt))
case uint16:
return enc.EncodeInt(int(vt))
case uint8:
return enc.EncodeInt(int(vt))
case float64:
return enc.EncodeFloat(vt)
case float32:
return enc.EncodeFloat32(vt)
case *EmbeddedJSON:
return enc.EncodeEmbeddedJSON(vt)
default:
return InvalidMarshalError(fmt.Sprintf(invalidMarshalErrorMsg, vt))
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"Encode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"switch",... | // Encode encodes a value to JSON.
//
// If Encode cannot find a way to encode the type to JSON
// it will return an InvalidMarshalError. | [
"Encode",
"encodes",
"a",
"value",
"to",
"JSON",
".",
"If",
"Encode",
"cannot",
"find",
"a",
"way",
"to",
"encode",
"the",
"type",
"to",
"JSON",
"it",
"will",
"return",
"an",
"InvalidMarshalError",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_interface.go#L11-L49 |
19,137 | francoispqt/gojay | encode_pool.go | BorrowEncoder | func BorrowEncoder(w io.Writer) *Encoder {
enc := encPool.Get().(*Encoder)
enc.w = w
enc.buf = enc.buf[:0]
enc.isPooled = 0
enc.err = nil
enc.hasKeys = false
enc.keys = nil
return enc
} | go | func BorrowEncoder(w io.Writer) *Encoder {
enc := encPool.Get().(*Encoder)
enc.w = w
enc.buf = enc.buf[:0]
enc.isPooled = 0
enc.err = nil
enc.hasKeys = false
enc.keys = nil
return enc
} | [
"func",
"BorrowEncoder",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"Encoder",
"{",
"enc",
":=",
"encPool",
".",
"Get",
"(",
")",
".",
"(",
"*",
"Encoder",
")",
"\n",
"enc",
".",
"w",
"=",
"w",
"\n",
"enc",
".",
"buf",
"=",
"enc",
".",
"buf",
"... | // BorrowEncoder borrows an Encoder from the pool. | [
"BorrowEncoder",
"borrows",
"an",
"Encoder",
"from",
"the",
"pool",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_pool.go#L35-L44 |
19,138 | francoispqt/gojay | encode_sqlnull.go | EncodeSQLNullString | func (enc *Encoder) EncodeSQLNullString(v *sql.NullString) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeString(v.String)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | go | func (enc *Encoder) EncodeSQLNullString(v *sql.NullString) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeString(v.String)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeSQLNullString",
"(",
"v",
"*",
"sql",
".",
"NullString",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",
")",
")",
"\n",
"... | // EncodeSQLNullString encodes a string to | [
"EncodeSQLNullString",
"encodes",
"a",
"string",
"to"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L6-L17 |
19,139 | francoispqt/gojay | encode_sqlnull.go | SQLNullString | func (enc *Encoder) SQLNullString(v *sql.NullString) {
enc.String(v.String)
} | go | func (enc *Encoder) SQLNullString(v *sql.NullString) {
enc.String(v.String)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullString",
"(",
"v",
"*",
"sql",
".",
"NullString",
")",
"{",
"enc",
".",
"String",
"(",
"v",
".",
"String",
")",
"\n",
"}"
] | // SQLNullString adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullString",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L54-L56 |
19,140 | francoispqt/gojay | encode_sqlnull.go | SQLNullStringOmitEmpty | func (enc *Encoder) SQLNullStringOmitEmpty(v *sql.NullString) {
if v != nil && v.Valid && v.String != "" {
enc.String(v.String)
}
} | go | func (enc *Encoder) SQLNullStringOmitEmpty(v *sql.NullString) {
if v != nil && v.Valid && v.String != "" {
enc.String(v.String)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullStringOmitEmpty",
"(",
"v",
"*",
"sql",
".",
"NullString",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"&&",
"v",
".",
"String",
"!=",
"\"",
"\"",
"{",
"enc",
".",
"String",
"(",
"v"... | // SQLNullStringOmitEmpty adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullStringOmitEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L59-L63 |
19,141 | francoispqt/gojay | encode_sqlnull.go | SQLNullStringNullEmpty | func (enc *Encoder) SQLNullStringNullEmpty(v *sql.NullString) {
if v != nil && v.Valid {
enc.StringNullEmpty(v.String)
}
} | go | func (enc *Encoder) SQLNullStringNullEmpty(v *sql.NullString) {
if v != nil && v.Valid {
enc.StringNullEmpty(v.String)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullStringNullEmpty",
"(",
"v",
"*",
"sql",
".",
"NullString",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"{",
"enc",
".",
"StringNullEmpty",
"(",
"v",
".",
"String",
")",
"\n",
"}",
"\n"... | // SQLNullStringNullEmpty adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullStringNullEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L66-L70 |
19,142 | francoispqt/gojay | encode_sqlnull.go | SQLNullStringKey | func (enc *Encoder) SQLNullStringKey(key string, v *sql.NullString) {
enc.StringKey(key, v.String)
} | go | func (enc *Encoder) SQLNullStringKey(key string, v *sql.NullString) {
enc.StringKey(key, v.String)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullStringKey",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullString",
")",
"{",
"enc",
".",
"StringKey",
"(",
"key",
",",
"v",
".",
"String",
")",
"\n",
"}"
] | // SQLNullStringKey adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullStringKey",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L73-L75 |
19,143 | francoispqt/gojay | encode_sqlnull.go | SQLNullStringKeyOmitEmpty | func (enc *Encoder) SQLNullStringKeyOmitEmpty(key string, v *sql.NullString) {
if v != nil && v.Valid && v.String != "" {
enc.StringKeyOmitEmpty(key, v.String)
}
} | go | func (enc *Encoder) SQLNullStringKeyOmitEmpty(key string, v *sql.NullString) {
if v != nil && v.Valid && v.String != "" {
enc.StringKeyOmitEmpty(key, v.String)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullStringKeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullString",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"&&",
"v",
".",
"String",
"!=",
"\"",
"\"",
"{",
"enc",
... | // SQLNullStringKeyOmitEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key | [
"SQLNullStringKeyOmitEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L79-L83 |
19,144 | francoispqt/gojay | encode_sqlnull.go | SQLNullStringKeyNullEmpty | func (enc *Encoder) SQLNullStringKeyNullEmpty(key string, v *sql.NullString) {
if v != nil && v.Valid {
enc.StringKeyNullEmpty(key, v.String)
}
} | go | func (enc *Encoder) SQLNullStringKeyNullEmpty(key string, v *sql.NullString) {
if v != nil && v.Valid {
enc.StringKeyNullEmpty(key, v.String)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullStringKeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullString",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"{",
"enc",
".",
"StringKeyNullEmpty",
"(",
"key",
",",
"v... | // SQLNullStringKeyNullEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key | [
"SQLNullStringKeyNullEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L87-L91 |
19,145 | francoispqt/gojay | encode_sqlnull.go | EncodeSQLNullInt64 | func (enc *Encoder) EncodeSQLNullInt64(v *sql.NullInt64) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeInt64(v.Int64)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | go | func (enc *Encoder) EncodeSQLNullInt64(v *sql.NullInt64) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeInt64(v.Int64)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeSQLNullInt64",
"(",
"v",
"*",
"sql",
".",
"NullInt64",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",
")",
")",
"\n",
"}"... | // NullInt64
// EncodeSQLNullInt64 encodes a string to | [
"NullInt64",
"EncodeSQLNullInt64",
"encodes",
"a",
"string",
"to"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L96-L107 |
19,146 | francoispqt/gojay | encode_sqlnull.go | AddSQLNullInt64Key | func (enc *Encoder) AddSQLNullInt64Key(key string, v *sql.NullInt64) {
enc.Int64Key(key, v.Int64)
} | go | func (enc *Encoder) AddSQLNullInt64Key(key string, v *sql.NullInt64) {
enc.Int64Key(key, v.Int64)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddSQLNullInt64Key",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullInt64",
")",
"{",
"enc",
".",
"Int64Key",
"(",
"key",
",",
"v",
".",
"Int64",
")",
"\n",
"}"
] | // AddSQLNullInt64Key adds a string to be encoded, must be used inside an object as it will encode a key | [
"AddSQLNullInt64Key",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L131-L133 |
19,147 | francoispqt/gojay | encode_sqlnull.go | AddSQLNullInt64KeyOmitEmpty | func (enc *Encoder) AddSQLNullInt64KeyOmitEmpty(key string, v *sql.NullInt64) {
if v != nil && v.Valid && v.Int64 != 0 {
enc.Int64KeyOmitEmpty(key, v.Int64)
}
} | go | func (enc *Encoder) AddSQLNullInt64KeyOmitEmpty(key string, v *sql.NullInt64) {
if v != nil && v.Valid && v.Int64 != 0 {
enc.Int64KeyOmitEmpty(key, v.Int64)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddSQLNullInt64KeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullInt64",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"&&",
"v",
".",
"Int64",
"!=",
"0",
"{",
"enc",
".",
... | // AddSQLNullInt64KeyOmitEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key | [
"AddSQLNullInt64KeyOmitEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L137-L141 |
19,148 | francoispqt/gojay | encode_sqlnull.go | SQLNullInt64 | func (enc *Encoder) SQLNullInt64(v *sql.NullInt64) {
enc.Int64(v.Int64)
} | go | func (enc *Encoder) SQLNullInt64(v *sql.NullInt64) {
enc.Int64(v.Int64)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullInt64",
"(",
"v",
"*",
"sql",
".",
"NullInt64",
")",
"{",
"enc",
".",
"Int64",
"(",
"v",
".",
"Int64",
")",
"\n",
"}"
] | // SQLNullInt64 adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullInt64",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L152-L154 |
19,149 | francoispqt/gojay | encode_sqlnull.go | SQLNullInt64OmitEmpty | func (enc *Encoder) SQLNullInt64OmitEmpty(v *sql.NullInt64) {
if v != nil && v.Valid && v.Int64 != 0 {
enc.Int64(v.Int64)
}
} | go | func (enc *Encoder) SQLNullInt64OmitEmpty(v *sql.NullInt64) {
if v != nil && v.Valid && v.Int64 != 0 {
enc.Int64(v.Int64)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullInt64OmitEmpty",
"(",
"v",
"*",
"sql",
".",
"NullInt64",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"&&",
"v",
".",
"Int64",
"!=",
"0",
"{",
"enc",
".",
"Int64",
"(",
"v",
".",
"I... | // SQLNullInt64OmitEmpty adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullInt64OmitEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L157-L161 |
19,150 | francoispqt/gojay | encode_sqlnull.go | SQLNullInt64NullEmpty | func (enc *Encoder) SQLNullInt64NullEmpty(v *sql.NullInt64) {
if v != nil && v.Valid {
enc.Int64NullEmpty(v.Int64)
}
} | go | func (enc *Encoder) SQLNullInt64NullEmpty(v *sql.NullInt64) {
if v != nil && v.Valid {
enc.Int64NullEmpty(v.Int64)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullInt64NullEmpty",
"(",
"v",
"*",
"sql",
".",
"NullInt64",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"{",
"enc",
".",
"Int64NullEmpty",
"(",
"v",
".",
"Int64",
")",
"\n",
"}",
"\n",
... | // SQLNullInt64NullEmpty adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullInt64NullEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L164-L168 |
19,151 | francoispqt/gojay | encode_sqlnull.go | SQLNullInt64KeyNullEmpty | func (enc *Encoder) SQLNullInt64KeyNullEmpty(key string, v *sql.NullInt64) {
if v != nil && v.Valid {
enc.Int64KeyNullEmpty(key, v.Int64)
}
} | go | func (enc *Encoder) SQLNullInt64KeyNullEmpty(key string, v *sql.NullInt64) {
if v != nil && v.Valid {
enc.Int64KeyNullEmpty(key, v.Int64)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullInt64KeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullInt64",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"{",
"enc",
".",
"Int64KeyNullEmpty",
"(",
"key",
",",
"v",
... | // SQLNullInt64KeyNullEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key | [
"SQLNullInt64KeyNullEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L185-L189 |
19,152 | francoispqt/gojay | encode_sqlnull.go | EncodeSQLNullFloat64 | func (enc *Encoder) EncodeSQLNullFloat64(v *sql.NullFloat64) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeFloat(v.Float64)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | go | func (enc *Encoder) EncodeSQLNullFloat64(v *sql.NullFloat64) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeFloat(v.Float64)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeSQLNullFloat64",
"(",
"v",
"*",
"sql",
".",
"NullFloat64",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",
")",
")",
"\n",
... | // NullFloat64
// EncodeSQLNullFloat64 encodes a string to | [
"NullFloat64",
"EncodeSQLNullFloat64",
"encodes",
"a",
"string",
"to"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L194-L205 |
19,153 | francoispqt/gojay | encode_sqlnull.go | SQLNullFloat64 | func (enc *Encoder) SQLNullFloat64(v *sql.NullFloat64) {
enc.Float64(v.Float64)
} | go | func (enc *Encoder) SQLNullFloat64(v *sql.NullFloat64) {
enc.Float64(v.Float64)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullFloat64",
"(",
"v",
"*",
"sql",
".",
"NullFloat64",
")",
"{",
"enc",
".",
"Float64",
"(",
"v",
".",
"Float64",
")",
"\n",
"}"
] | // SQLNullFloat64 adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullFloat64",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L250-L252 |
19,154 | francoispqt/gojay | encode_sqlnull.go | SQLNullFloat64OmitEmpty | func (enc *Encoder) SQLNullFloat64OmitEmpty(v *sql.NullFloat64) {
if v != nil && v.Valid && v.Float64 != 0 {
enc.Float64(v.Float64)
}
} | go | func (enc *Encoder) SQLNullFloat64OmitEmpty(v *sql.NullFloat64) {
if v != nil && v.Valid && v.Float64 != 0 {
enc.Float64(v.Float64)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullFloat64OmitEmpty",
"(",
"v",
"*",
"sql",
".",
"NullFloat64",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"&&",
"v",
".",
"Float64",
"!=",
"0",
"{",
"enc",
".",
"Float64",
"(",
"v",
"... | // SQLNullFloat64OmitEmpty adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullFloat64OmitEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L255-L259 |
19,155 | francoispqt/gojay | encode_sqlnull.go | SQLNullFloat64NullEmpty | func (enc *Encoder) SQLNullFloat64NullEmpty(v *sql.NullFloat64) {
if v != nil && v.Valid {
enc.Float64NullEmpty(v.Float64)
}
} | go | func (enc *Encoder) SQLNullFloat64NullEmpty(v *sql.NullFloat64) {
if v != nil && v.Valid {
enc.Float64NullEmpty(v.Float64)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullFloat64NullEmpty",
"(",
"v",
"*",
"sql",
".",
"NullFloat64",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"{",
"enc",
".",
"Float64NullEmpty",
"(",
"v",
".",
"Float64",
")",
"\n",
"}",
... | // SQLNullFloat64NullEmpty adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullFloat64NullEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L262-L266 |
19,156 | francoispqt/gojay | encode_sqlnull.go | SQLNullFloat64Key | func (enc *Encoder) SQLNullFloat64Key(key string, v *sql.NullFloat64) {
enc.Float64Key(key, v.Float64)
} | go | func (enc *Encoder) SQLNullFloat64Key(key string, v *sql.NullFloat64) {
enc.Float64Key(key, v.Float64)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullFloat64Key",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullFloat64",
")",
"{",
"enc",
".",
"Float64Key",
"(",
"key",
",",
"v",
".",
"Float64",
")",
"\n",
"}"
] | // SQLNullFloat64Key adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullFloat64Key",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L269-L271 |
19,157 | francoispqt/gojay | encode_sqlnull.go | SQLNullFloat64KeyOmitEmpty | func (enc *Encoder) SQLNullFloat64KeyOmitEmpty(key string, v *sql.NullFloat64) {
if v != nil && v.Valid && v.Float64 != 0 {
enc.Float64KeyOmitEmpty(key, v.Float64)
}
} | go | func (enc *Encoder) SQLNullFloat64KeyOmitEmpty(key string, v *sql.NullFloat64) {
if v != nil && v.Valid && v.Float64 != 0 {
enc.Float64KeyOmitEmpty(key, v.Float64)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullFloat64KeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullFloat64",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"&&",
"v",
".",
"Float64",
"!=",
"0",
"{",
"enc",
".",... | // SQLNullFloat64KeyOmitEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key | [
"SQLNullFloat64KeyOmitEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L275-L279 |
19,158 | francoispqt/gojay | encode_sqlnull.go | SQLNullFloat64KeyNullEmpty | func (enc *Encoder) SQLNullFloat64KeyNullEmpty(key string, v *sql.NullFloat64) {
if v != nil && v.Valid {
enc.Float64KeyNullEmpty(key, v.Float64)
}
} | go | func (enc *Encoder) SQLNullFloat64KeyNullEmpty(key string, v *sql.NullFloat64) {
if v != nil && v.Valid {
enc.Float64KeyNullEmpty(key, v.Float64)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullFloat64KeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullFloat64",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"{",
"enc",
".",
"Float64KeyNullEmpty",
"(",
"key",
",",
... | // SQLNullFloat64KeyNullEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key | [
"SQLNullFloat64KeyNullEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L283-L287 |
19,159 | francoispqt/gojay | encode_sqlnull.go | EncodeSQLNullBool | func (enc *Encoder) EncodeSQLNullBool(v *sql.NullBool) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeBool(v.Bool)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | go | func (enc *Encoder) EncodeSQLNullBool(v *sql.NullBool) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeBool(v.Bool)
_, err := enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeSQLNullBool",
"(",
"v",
"*",
"sql",
".",
"NullBool",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
... | // NullBool
// EncodeSQLNullBool encodes a string to | [
"NullBool",
"EncodeSQLNullBool",
"encodes",
"a",
"string",
"to"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L292-L303 |
19,160 | francoispqt/gojay | encode_sqlnull.go | AddSQLNullBoolKey | func (enc *Encoder) AddSQLNullBoolKey(key string, v *sql.NullBool) {
enc.BoolKey(key, v.Bool)
} | go | func (enc *Encoder) AddSQLNullBoolKey(key string, v *sql.NullBool) {
enc.BoolKey(key, v.Bool)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddSQLNullBoolKey",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullBool",
")",
"{",
"enc",
".",
"BoolKey",
"(",
"key",
",",
"v",
".",
"Bool",
")",
"\n",
"}"
] | // AddSQLNullBoolKey adds a string to be encoded, must be used inside an object as it will encode a key | [
"AddSQLNullBoolKey",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L319-L321 |
19,161 | francoispqt/gojay | encode_sqlnull.go | SQLNullBool | func (enc *Encoder) SQLNullBool(v *sql.NullBool) {
enc.Bool(v.Bool)
} | go | func (enc *Encoder) SQLNullBool(v *sql.NullBool) {
enc.Bool(v.Bool)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullBool",
"(",
"v",
"*",
"sql",
".",
"NullBool",
")",
"{",
"enc",
".",
"Bool",
"(",
"v",
".",
"Bool",
")",
"\n",
"}"
] | // SQLNullBool adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullBool",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L340-L342 |
19,162 | francoispqt/gojay | encode_sqlnull.go | SQLNullBoolOmitEmpty | func (enc *Encoder) SQLNullBoolOmitEmpty(v *sql.NullBool) {
if v != nil && v.Valid && v.Bool != false {
enc.Bool(v.Bool)
}
} | go | func (enc *Encoder) SQLNullBoolOmitEmpty(v *sql.NullBool) {
if v != nil && v.Valid && v.Bool != false {
enc.Bool(v.Bool)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullBoolOmitEmpty",
"(",
"v",
"*",
"sql",
".",
"NullBool",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"&&",
"v",
".",
"Bool",
"!=",
"false",
"{",
"enc",
".",
"Bool",
"(",
"v",
".",
"B... | // SQLNullBoolOmitEmpty adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullBoolOmitEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L345-L349 |
19,163 | francoispqt/gojay | encode_sqlnull.go | SQLNullBoolNullEmpty | func (enc *Encoder) SQLNullBoolNullEmpty(v *sql.NullBool) {
if v != nil && v.Valid {
enc.BoolNullEmpty(v.Bool)
}
} | go | func (enc *Encoder) SQLNullBoolNullEmpty(v *sql.NullBool) {
if v != nil && v.Valid {
enc.BoolNullEmpty(v.Bool)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullBoolNullEmpty",
"(",
"v",
"*",
"sql",
".",
"NullBool",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"{",
"enc",
".",
"BoolNullEmpty",
"(",
"v",
".",
"Bool",
")",
"\n",
"}",
"\n",
"}"
... | // SQLNullBoolNullEmpty adds a string to be encoded, must be used inside an object as it will encode a key | [
"SQLNullBoolNullEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L352-L356 |
19,164 | francoispqt/gojay | encode_sqlnull.go | SQLNullBoolKeyOmitEmpty | func (enc *Encoder) SQLNullBoolKeyOmitEmpty(key string, v *sql.NullBool) {
if v != nil && v.Valid && v.Bool != false {
enc.BoolKeyOmitEmpty(key, v.Bool)
}
} | go | func (enc *Encoder) SQLNullBoolKeyOmitEmpty(key string, v *sql.NullBool) {
if v != nil && v.Valid && v.Bool != false {
enc.BoolKeyOmitEmpty(key, v.Bool)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullBoolKeyOmitEmpty",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullBool",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"&&",
"v",
".",
"Bool",
"!=",
"false",
"{",
"enc",
".",
"B... | // SQLNullBoolKeyOmitEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key | [
"SQLNullBoolKeyOmitEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L365-L369 |
19,165 | francoispqt/gojay | encode_sqlnull.go | SQLNullBoolKeyNullEmpty | func (enc *Encoder) SQLNullBoolKeyNullEmpty(key string, v *sql.NullBool) {
if v != nil && v.Valid {
enc.BoolKeyNullEmpty(key, v.Bool)
}
} | go | func (enc *Encoder) SQLNullBoolKeyNullEmpty(key string, v *sql.NullBool) {
if v != nil && v.Valid {
enc.BoolKeyNullEmpty(key, v.Bool)
}
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"SQLNullBoolKeyNullEmpty",
"(",
"key",
"string",
",",
"v",
"*",
"sql",
".",
"NullBool",
")",
"{",
"if",
"v",
"!=",
"nil",
"&&",
"v",
".",
"Valid",
"{",
"enc",
".",
"BoolKeyNullEmpty",
"(",
"key",
",",
"v",
"... | // SQLNullBoolKeyNullEmpty adds a string to be encoded or skips it if it is zero value.
// Must be used inside an object as it will encode a key | [
"SQLNullBoolKeyNullEmpty",
"adds",
"a",
"string",
"to",
"be",
"encoded",
"or",
"skips",
"it",
"if",
"it",
"is",
"zero",
"value",
".",
"Must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_sqlnull.go#L373-L377 |
19,166 | francoispqt/gojay | encode_null.go | Null | func (enc *Encoder) Null() {
enc.grow(5)
r := enc.getPreviousRune()
if r != '[' {
enc.writeByte(',')
}
enc.writeBytes(nullBytes)
} | go | func (enc *Encoder) Null() {
enc.grow(5)
r := enc.getPreviousRune()
if r != '[' {
enc.writeByte(',')
}
enc.writeBytes(nullBytes)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"Null",
"(",
")",
"{",
"enc",
".",
"grow",
"(",
"5",
")",
"\n",
"r",
":=",
"enc",
".",
"getPreviousRune",
"(",
")",
"\n",
"if",
"r",
"!=",
"'['",
"{",
"enc",
".",
"writeByte",
"(",
"','",
")",
"\n",
"}... | // Null adds a `null` to be encoded. Must be used while encoding an array.` | [
"Null",
"adds",
"a",
"null",
"to",
"be",
"encoded",
".",
"Must",
"be",
"used",
"while",
"encoding",
"an",
"array",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_null.go#L9-L16 |
19,167 | francoispqt/gojay | encode_null.go | NullKey | func (enc *Encoder) NullKey(key string) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKey)
enc.writeBytes(nullBytes)
} | go | func (enc *Encoder) NullKey(key string) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKey)
enc.writeBytes(nullBytes)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"NullKey",
"(",
"key",
"string",
")",
"{",
"if",
"enc",
".",
"hasKeys",
"{",
"if",
"!",
"enc",
".",
"keyExists",
"(",
"key",
")",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"enc",
".",
"grow",
"(",
"5",
... | // NullKey adds a `null` to be encoded. Must be used while encoding an array.` | [
"NullKey",
"adds",
"a",
"null",
"to",
"be",
"encoded",
".",
"Must",
"be",
"used",
"while",
"encoding",
"an",
"array",
"."
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_null.go#L24-L39 |
19,168 | francoispqt/gojay | encode_object.go | EncodeObject | func (enc *Encoder) EncodeObject(v MarshalerJSONObject) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, err := enc.encodeObject(v)
if err != nil {
enc.err = err
return err
}
_, err = enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | go | func (enc *Encoder) EncodeObject(v MarshalerJSONObject) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, err := enc.encodeObject(v)
if err != nil {
enc.err = err
return err
}
_, err = enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeObject",
"(",
"v",
"MarshalerJSONObject",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"_",
... | // EncodeObject encodes an object to JSON | [
"EncodeObject",
"encodes",
"an",
"object",
"to",
"JSON"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_object.go#L9-L24 |
19,169 | francoispqt/gojay | encode_object.go | EncodeObjectKeys | func (enc *Encoder) EncodeObjectKeys(v MarshalerJSONObject, keys []string) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
enc.hasKeys = true
enc.keys = keys
_, err := enc.encodeObject(v)
if err != nil {
enc.err = err
return err
}
_, err = enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | go | func (enc *Encoder) EncodeObjectKeys(v MarshalerJSONObject, keys []string) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
enc.hasKeys = true
enc.keys = keys
_, err := enc.encodeObject(v)
if err != nil {
enc.err = err
return err
}
_, err = enc.Write()
if err != nil {
enc.err = err
return err
}
return nil
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"EncodeObjectKeys",
"(",
"v",
"MarshalerJSONObject",
",",
"keys",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"enc",
".",
"isPooled",
"==",
"1",
"{",
"panic",
"(",
"InvalidUsagePooledEncoderError",
"(",
"\"",
"\"",... | // EncodeObjectKeys encodes an object to JSON | [
"EncodeObjectKeys",
"encodes",
"an",
"object",
"to",
"JSON"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_object.go#L27-L44 |
19,170 | francoispqt/gojay | encode_object.go | AddObjectKey | func (enc *Encoder) AddObjectKey(key string, v MarshalerJSONObject) {
enc.ObjectKey(key, v)
} | go | func (enc *Encoder) AddObjectKey(key string, v MarshalerJSONObject) {
enc.ObjectKey(key, v)
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"AddObjectKey",
"(",
"key",
"string",
",",
"v",
"MarshalerJSONObject",
")",
"{",
"enc",
".",
"ObjectKey",
"(",
"key",
",",
"v",
")",
"\n",
"}"
] | // AddObjectKey adds a struct to be encoded, must be used inside an object as it will encode a key
// value must implement MarshalerJSONObject | [
"AddObjectKey",
"adds",
"a",
"struct",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"value",
"must",
"implement",
"MarshalerJSONObject"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_object.go#L82-L84 |
19,171 | francoispqt/gojay | encode_object.go | ObjectKey | func (enc *Encoder) ObjectKey(key string, v MarshalerJSONObject) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if v.IsNil() {
enc.grow(2 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyObj)
enc.writeByte('}')
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyObj)
var origHasKeys = enc.hasKeys
var origKeys = enc.keys
enc.hasKeys = false
enc.keys = nil
v.MarshalJSONObject(enc)
enc.hasKeys = origHasKeys
enc.keys = origKeys
enc.writeByte('}')
} | go | func (enc *Encoder) ObjectKey(key string, v MarshalerJSONObject) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if v.IsNil() {
enc.grow(2 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyObj)
enc.writeByte('}')
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyObj)
var origHasKeys = enc.hasKeys
var origKeys = enc.keys
enc.hasKeys = false
enc.keys = nil
v.MarshalJSONObject(enc)
enc.hasKeys = origHasKeys
enc.keys = origKeys
enc.writeByte('}')
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"ObjectKey",
"(",
"key",
"string",
",",
"v",
"MarshalerJSONObject",
")",
"{",
"if",
"enc",
".",
"hasKeys",
"{",
"if",
"!",
"enc",
".",
"keyExists",
"(",
"key",
")",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",... | // ObjectKey adds a struct to be encoded, must be used inside an object as it will encode a key
// value must implement MarshalerJSONObject | [
"ObjectKey",
"adds",
"a",
"struct",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
"value",
"must",
"implement",
"MarshalerJSONObject"
] | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_object.go#L223-L261 |
19,172 | francoispqt/gojay | encode_object.go | ObjectKeyWithKeys | func (enc *Encoder) ObjectKeyWithKeys(key string, value MarshalerJSONObject, keys []string) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if value.IsNil() {
enc.grow(2 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyObj)
enc.writeByte('}')
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyObj)
var origKeys = enc.keys
var origHasKeys = enc.hasKeys
enc.hasKeys = true
enc.keys = keys
value.MarshalJSONObject(enc)
enc.hasKeys = origHasKeys
enc.keys = origKeys
enc.writeByte('}')
} | go | func (enc *Encoder) ObjectKeyWithKeys(key string, value MarshalerJSONObject, keys []string) {
if enc.hasKeys {
if !enc.keyExists(key) {
return
}
}
if value.IsNil() {
enc.grow(2 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyObj)
enc.writeByte('}')
return
}
enc.grow(5 + len(key))
r := enc.getPreviousRune()
if r != '{' {
enc.writeByte(',')
}
enc.writeByte('"')
enc.writeStringEscape(key)
enc.writeBytes(objKeyObj)
var origKeys = enc.keys
var origHasKeys = enc.hasKeys
enc.hasKeys = true
enc.keys = keys
value.MarshalJSONObject(enc)
enc.hasKeys = origHasKeys
enc.keys = origKeys
enc.writeByte('}')
} | [
"func",
"(",
"enc",
"*",
"Encoder",
")",
"ObjectKeyWithKeys",
"(",
"key",
"string",
",",
"value",
"MarshalerJSONObject",
",",
"keys",
"[",
"]",
"string",
")",
"{",
"if",
"enc",
".",
"hasKeys",
"{",
"if",
"!",
"enc",
".",
"keyExists",
"(",
"key",
")",
... | // ObjectKeyWithKeys adds a struct to be encoded, must be used inside an object as it will encode a key.
// Value must implement MarshalerJSONObject. It will only encode the keys in keys. | [
"ObjectKeyWithKeys",
"adds",
"a",
"struct",
"to",
"be",
"encoded",
"must",
"be",
"used",
"inside",
"an",
"object",
"as",
"it",
"will",
"encode",
"a",
"key",
".",
"Value",
"must",
"implement",
"MarshalerJSONObject",
".",
"It",
"will",
"only",
"encode",
"the",... | e46791d21b5e950e35a725e34cbee72354cc7d10 | https://github.com/francoispqt/gojay/blob/e46791d21b5e950e35a725e34cbee72354cc7d10/encode_object.go#L265-L299 |
19,173 | golang/snappy | encode.go | Encode | func Encode(dst, src []byte) []byte {
if n := MaxEncodedLen(len(src)); n < 0 {
panic(ErrTooLarge)
} else if len(dst) < n {
dst = make([]byte, n)
}
// The block starts with the varint-encoded length of the decompressed bytes.
d := binary.PutUvarint(dst, uint64(len(src)))
for len(src) > 0 {
p := src
src = nil
if len(p) > maxBlockSize {
p, src = p[:maxBlockSize], p[maxBlockSize:]
}
if len(p) < minNonLiteralBlockSize {
d += emitLiteral(dst[d:], p)
} else {
d += encodeBlock(dst[d:], p)
}
}
return dst[:d]
} | go | func Encode(dst, src []byte) []byte {
if n := MaxEncodedLen(len(src)); n < 0 {
panic(ErrTooLarge)
} else if len(dst) < n {
dst = make([]byte, n)
}
// The block starts with the varint-encoded length of the decompressed bytes.
d := binary.PutUvarint(dst, uint64(len(src)))
for len(src) > 0 {
p := src
src = nil
if len(p) > maxBlockSize {
p, src = p[:maxBlockSize], p[maxBlockSize:]
}
if len(p) < minNonLiteralBlockSize {
d += emitLiteral(dst[d:], p)
} else {
d += encodeBlock(dst[d:], p)
}
}
return dst[:d]
} | [
"func",
"Encode",
"(",
"dst",
",",
"src",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"if",
"n",
":=",
"MaxEncodedLen",
"(",
"len",
"(",
"src",
")",
")",
";",
"n",
"<",
"0",
"{",
"panic",
"(",
"ErrTooLarge",
")",
"\n",
"}",
"else",
"if",
"l... | // Encode returns the encoded form of src. The returned slice may be a sub-
// slice of dst if dst was large enough to hold the entire encoded block.
// Otherwise, a newly allocated slice will be returned.
//
// The dst and src must not overlap. It is valid to pass a nil dst. | [
"Encode",
"returns",
"the",
"encoded",
"form",
"of",
"src",
".",
"The",
"returned",
"slice",
"may",
"be",
"a",
"sub",
"-",
"slice",
"of",
"dst",
"if",
"dst",
"was",
"large",
"enough",
"to",
"hold",
"the",
"entire",
"encoded",
"block",
".",
"Otherwise",
... | 2a8bb927dd31d8daada140a5d09578521ce5c36a | https://github.com/golang/snappy/blob/2a8bb927dd31d8daada140a5d09578521ce5c36a/encode.go#L18-L41 |
19,174 | golang/snappy | encode.go | MaxEncodedLen | func MaxEncodedLen(srcLen int) int {
n := uint64(srcLen)
if n > 0xffffffff {
return -1
}
// Compressed data can be defined as:
// compressed := item* literal*
// item := literal* copy
//
// The trailing literal sequence has a space blowup of at most 62/60
// since a literal of length 60 needs one tag byte + one extra byte
// for length information.
//
// Item blowup is trickier to measure. Suppose the "copy" op copies
// 4 bytes of data. Because of a special check in the encoding code,
// we produce a 4-byte copy only if the offset is < 65536. Therefore
// the copy op takes 3 bytes to encode, and this type of item leads
// to at most the 62/60 blowup for representing literals.
//
// Suppose the "copy" op copies 5 bytes of data. If the offset is big
// enough, it will take 5 bytes to encode the copy op. Therefore the
// worst case here is a one-byte literal followed by a five-byte copy.
// That is, 6 bytes of input turn into 7 bytes of "compressed" data.
//
// This last factor dominates the blowup, so the final estimate is:
n = 32 + n + n/6
if n > 0xffffffff {
return -1
}
return int(n)
} | go | func MaxEncodedLen(srcLen int) int {
n := uint64(srcLen)
if n > 0xffffffff {
return -1
}
// Compressed data can be defined as:
// compressed := item* literal*
// item := literal* copy
//
// The trailing literal sequence has a space blowup of at most 62/60
// since a literal of length 60 needs one tag byte + one extra byte
// for length information.
//
// Item blowup is trickier to measure. Suppose the "copy" op copies
// 4 bytes of data. Because of a special check in the encoding code,
// we produce a 4-byte copy only if the offset is < 65536. Therefore
// the copy op takes 3 bytes to encode, and this type of item leads
// to at most the 62/60 blowup for representing literals.
//
// Suppose the "copy" op copies 5 bytes of data. If the offset is big
// enough, it will take 5 bytes to encode the copy op. Therefore the
// worst case here is a one-byte literal followed by a five-byte copy.
// That is, 6 bytes of input turn into 7 bytes of "compressed" data.
//
// This last factor dominates the blowup, so the final estimate is:
n = 32 + n + n/6
if n > 0xffffffff {
return -1
}
return int(n)
} | [
"func",
"MaxEncodedLen",
"(",
"srcLen",
"int",
")",
"int",
"{",
"n",
":=",
"uint64",
"(",
"srcLen",
")",
"\n",
"if",
"n",
">",
"0xffffffff",
"{",
"return",
"-",
"1",
"\n",
"}",
"\n",
"// Compressed data can be defined as:",
"// compressed := item* literal*",
... | // MaxEncodedLen returns the maximum length of a snappy block, given its
// uncompressed length.
//
// It will return a negative value if srcLen is too large to encode. | [
"MaxEncodedLen",
"returns",
"the",
"maximum",
"length",
"of",
"a",
"snappy",
"block",
"given",
"its",
"uncompressed",
"length",
".",
"It",
"will",
"return",
"a",
"negative",
"value",
"if",
"srcLen",
"is",
"too",
"large",
"to",
"encode",
"."
] | 2a8bb927dd31d8daada140a5d09578521ce5c36a | https://github.com/golang/snappy/blob/2a8bb927dd31d8daada140a5d09578521ce5c36a/encode.go#L76-L106 |
19,175 | golang/snappy | encode.go | Close | func (w *Writer) Close() error {
w.Flush()
ret := w.err
if w.err == nil {
w.err = errClosed
}
return ret
} | go | func (w *Writer) Close() error {
w.Flush()
ret := w.err
if w.err == nil {
w.err = errClosed
}
return ret
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Close",
"(",
")",
"error",
"{",
"w",
".",
"Flush",
"(",
")",
"\n",
"ret",
":=",
"w",
".",
"err",
"\n",
"if",
"w",
".",
"err",
"==",
"nil",
"{",
"w",
".",
"err",
"=",
"errClosed",
"\n",
"}",
"\n",
"retu... | // Close calls Flush and then closes the Writer. | [
"Close",
"calls",
"Flush",
"and",
"then",
"closes",
"the",
"Writer",
"."
] | 2a8bb927dd31d8daada140a5d09578521ce5c36a | https://github.com/golang/snappy/blob/2a8bb927dd31d8daada140a5d09578521ce5c36a/encode.go#L278-L285 |
19,176 | golang/snappy | decode.go | Decode | func Decode(dst, src []byte) ([]byte, error) {
dLen, s, err := decodedLen(src)
if err != nil {
return nil, err
}
if dLen <= len(dst) {
dst = dst[:dLen]
} else {
dst = make([]byte, dLen)
}
switch decode(dst, src[s:]) {
case 0:
return dst, nil
case decodeErrCodeUnsupportedLiteralLength:
return nil, errUnsupportedLiteralLength
}
return nil, ErrCorrupt
} | go | func Decode(dst, src []byte) ([]byte, error) {
dLen, s, err := decodedLen(src)
if err != nil {
return nil, err
}
if dLen <= len(dst) {
dst = dst[:dLen]
} else {
dst = make([]byte, dLen)
}
switch decode(dst, src[s:]) {
case 0:
return dst, nil
case decodeErrCodeUnsupportedLiteralLength:
return nil, errUnsupportedLiteralLength
}
return nil, ErrCorrupt
} | [
"func",
"Decode",
"(",
"dst",
",",
"src",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"dLen",
",",
"s",
",",
"err",
":=",
"decodedLen",
"(",
"src",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err... | // Decode returns the decoded form of src. The returned slice may be a sub-
// slice of dst if dst was large enough to hold the entire decoded block.
// Otherwise, a newly allocated slice will be returned.
//
// The dst and src must not overlap. It is valid to pass a nil dst. | [
"Decode",
"returns",
"the",
"decoded",
"form",
"of",
"src",
".",
"The",
"returned",
"slice",
"may",
"be",
"a",
"sub",
"-",
"slice",
"of",
"dst",
"if",
"dst",
"was",
"large",
"enough",
"to",
"hold",
"the",
"entire",
"decoded",
"block",
".",
"Otherwise",
... | 2a8bb927dd31d8daada140a5d09578521ce5c36a | https://github.com/golang/snappy/blob/2a8bb927dd31d8daada140a5d09578521ce5c36a/decode.go#L55-L72 |
19,177 | coreos/go-iptables | iptables/iptables.go | IsNotExist | func (e *Error) IsNotExist() bool {
return e.ExitStatus() == 1 &&
(e.msg == fmt.Sprintf("%s: Bad rule (does a matching rule exist in that chain?).\n", getIptablesCommand(e.proto)) ||
e.msg == fmt.Sprintf("%s: No chain/target/match by that name.\n", getIptablesCommand(e.proto)))
} | go | func (e *Error) IsNotExist() bool {
return e.ExitStatus() == 1 &&
(e.msg == fmt.Sprintf("%s: Bad rule (does a matching rule exist in that chain?).\n", getIptablesCommand(e.proto)) ||
e.msg == fmt.Sprintf("%s: No chain/target/match by that name.\n", getIptablesCommand(e.proto)))
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"IsNotExist",
"(",
")",
"bool",
"{",
"return",
"e",
".",
"ExitStatus",
"(",
")",
"==",
"1",
"&&",
"(",
"e",
".",
"msg",
"==",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"getIptablesCommand",
"(",
"e",... | // IsNotExist returns true if the error is due to the chain or rule not existing | [
"IsNotExist",
"returns",
"true",
"if",
"the",
"error",
"is",
"due",
"to",
"the",
"chain",
"or",
"rule",
"not",
"existing"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L50-L54 |
19,178 | coreos/go-iptables | iptables/iptables.go | NewWithProtocol | func NewWithProtocol(proto Protocol) (*IPTables, error) {
path, err := exec.LookPath(getIptablesCommand(proto))
if err != nil {
return nil, err
}
vstring, err := getIptablesVersionString(path)
v1, v2, v3, mode, err := extractIptablesVersion(vstring)
checkPresent, waitPresent, randomFullyPresent := getIptablesCommandSupport(v1, v2, v3)
ipt := IPTables{
path: path,
proto: proto,
hasCheck: checkPresent,
hasWait: waitPresent,
hasRandomFully: randomFullyPresent,
v1: v1,
v2: v2,
v3: v3,
mode: mode,
}
return &ipt, nil
} | go | func NewWithProtocol(proto Protocol) (*IPTables, error) {
path, err := exec.LookPath(getIptablesCommand(proto))
if err != nil {
return nil, err
}
vstring, err := getIptablesVersionString(path)
v1, v2, v3, mode, err := extractIptablesVersion(vstring)
checkPresent, waitPresent, randomFullyPresent := getIptablesCommandSupport(v1, v2, v3)
ipt := IPTables{
path: path,
proto: proto,
hasCheck: checkPresent,
hasWait: waitPresent,
hasRandomFully: randomFullyPresent,
v1: v1,
v2: v2,
v3: v3,
mode: mode,
}
return &ipt, nil
} | [
"func",
"NewWithProtocol",
"(",
"proto",
"Protocol",
")",
"(",
"*",
"IPTables",
",",
"error",
")",
"{",
"path",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"getIptablesCommand",
"(",
"proto",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // New creates a new IPTables for the given proto.
// The proto will determine which command is used, either "iptables" or "ip6tables". | [
"New",
"creates",
"a",
"new",
"IPTables",
"for",
"the",
"given",
"proto",
".",
"The",
"proto",
"will",
"determine",
"which",
"command",
"is",
"used",
"either",
"iptables",
"or",
"ip6tables",
"."
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L84-L106 |
19,179 | coreos/go-iptables | iptables/iptables.go | ListChains | func (ipt *IPTables) ListChains(table string) ([]string, error) {
args := []string{"-t", table, "-S"}
result, err := ipt.executeList(args)
if err != nil {
return nil, err
}
// Iterate over rules to find all default (-P) and user-specified (-N) chains.
// Chains definition always come before rules.
// Format is the following:
// -P OUTPUT ACCEPT
// -N Custom
var chains []string
for _, val := range result {
if strings.HasPrefix(val, "-P") || strings.HasPrefix(val, "-N") {
chains = append(chains, strings.Fields(val)[1])
} else {
break
}
}
return chains, nil
} | go | func (ipt *IPTables) ListChains(table string) ([]string, error) {
args := []string{"-t", table, "-S"}
result, err := ipt.executeList(args)
if err != nil {
return nil, err
}
// Iterate over rules to find all default (-P) and user-specified (-N) chains.
// Chains definition always come before rules.
// Format is the following:
// -P OUTPUT ACCEPT
// -N Custom
var chains []string
for _, val := range result {
if strings.HasPrefix(val, "-P") || strings.HasPrefix(val, "-N") {
chains = append(chains, strings.Fields(val)[1])
} else {
break
}
}
return chains, nil
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"ListChains",
"(",
"table",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"table",
",",
"\"",
"\"",
"}",
"\n\n",
"result",
",",
... | // ListChains returns a slice containing the name of each chain in the specified table. | [
"ListChains",
"returns",
"a",
"slice",
"containing",
"the",
"name",
"of",
"each",
"chain",
"in",
"the",
"specified",
"table",
"."
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L177-L199 |
19,180 | coreos/go-iptables | iptables/iptables.go | Stats | func (ipt *IPTables) Stats(table, chain string) ([][]string, error) {
args := []string{"-t", table, "-L", chain, "-n", "-v", "-x"}
lines, err := ipt.executeList(args)
if err != nil {
return nil, err
}
appendSubnet := func(addr string) string {
if strings.IndexByte(addr, byte('/')) < 0 {
if strings.IndexByte(addr, '.') < 0 {
return addr + "/128"
}
return addr + "/32"
}
return addr
}
ipv6 := ipt.proto == ProtocolIPv6
rows := [][]string{}
for i, line := range lines {
// Skip over chain name and field header
if i < 2 {
continue
}
// Fields:
// 0=pkts 1=bytes 2=target 3=prot 4=opt 5=in 6=out 7=source 8=destination 9=options
line = strings.TrimSpace(line)
fields := strings.Fields(line)
// The ip6tables verbose output cannot be naively split due to the default "opt"
// field containing 2 single spaces.
if ipv6 {
// Check if field 6 is "opt" or "source" address
dest := fields[6]
ip, _, _ := net.ParseCIDR(dest)
if ip == nil {
ip = net.ParseIP(dest)
}
// If we detected a CIDR or IP, the "opt" field is empty.. insert it.
if ip != nil {
f := []string{}
f = append(f, fields[:4]...)
f = append(f, " ") // Empty "opt" field for ip6tables
f = append(f, fields[4:]...)
fields = f
}
}
// Adjust "source" and "destination" to include netmask, to match regular
// List output
fields[7] = appendSubnet(fields[7])
fields[8] = appendSubnet(fields[8])
// Combine "options" fields 9... into a single space-delimited field.
options := fields[9:]
fields = fields[:9]
fields = append(fields, strings.Join(options, " "))
rows = append(rows, fields)
}
return rows, nil
} | go | func (ipt *IPTables) Stats(table, chain string) ([][]string, error) {
args := []string{"-t", table, "-L", chain, "-n", "-v", "-x"}
lines, err := ipt.executeList(args)
if err != nil {
return nil, err
}
appendSubnet := func(addr string) string {
if strings.IndexByte(addr, byte('/')) < 0 {
if strings.IndexByte(addr, '.') < 0 {
return addr + "/128"
}
return addr + "/32"
}
return addr
}
ipv6 := ipt.proto == ProtocolIPv6
rows := [][]string{}
for i, line := range lines {
// Skip over chain name and field header
if i < 2 {
continue
}
// Fields:
// 0=pkts 1=bytes 2=target 3=prot 4=opt 5=in 6=out 7=source 8=destination 9=options
line = strings.TrimSpace(line)
fields := strings.Fields(line)
// The ip6tables verbose output cannot be naively split due to the default "opt"
// field containing 2 single spaces.
if ipv6 {
// Check if field 6 is "opt" or "source" address
dest := fields[6]
ip, _, _ := net.ParseCIDR(dest)
if ip == nil {
ip = net.ParseIP(dest)
}
// If we detected a CIDR or IP, the "opt" field is empty.. insert it.
if ip != nil {
f := []string{}
f = append(f, fields[:4]...)
f = append(f, " ") // Empty "opt" field for ip6tables
f = append(f, fields[4:]...)
fields = f
}
}
// Adjust "source" and "destination" to include netmask, to match regular
// List output
fields[7] = appendSubnet(fields[7])
fields[8] = appendSubnet(fields[8])
// Combine "options" fields 9... into a single space-delimited field.
options := fields[9:]
fields = fields[:9]
fields = append(fields, strings.Join(options, " "))
rows = append(rows, fields)
}
return rows, nil
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"Stats",
"(",
"table",
",",
"chain",
"string",
")",
"(",
"[",
"]",
"[",
"]",
"string",
",",
"error",
")",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"table",
",",
"\"",
"\"",
",",
"c... | // Stats lists rules including the byte and packet counts | [
"Stats",
"lists",
"rules",
"including",
"the",
"byte",
"and",
"packet",
"counts"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L202-L265 |
19,181 | coreos/go-iptables | iptables/iptables.go | NewChain | func (ipt *IPTables) NewChain(table, chain string) error {
return ipt.run("-t", table, "-N", chain)
} | go | func (ipt *IPTables) NewChain(table, chain string) error {
return ipt.run("-t", table, "-N", chain)
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"NewChain",
"(",
"table",
",",
"chain",
"string",
")",
"error",
"{",
"return",
"ipt",
".",
"run",
"(",
"\"",
"\"",
",",
"table",
",",
"\"",
"\"",
",",
"chain",
")",
"\n",
"}"
] | // NewChain creates a new chain in the specified table.
// If the chain already exists, it will result in an error. | [
"NewChain",
"creates",
"a",
"new",
"chain",
"in",
"the",
"specified",
"table",
".",
"If",
"the",
"chain",
"already",
"exists",
"it",
"will",
"result",
"in",
"an",
"error",
"."
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L301-L303 |
19,182 | coreos/go-iptables | iptables/iptables.go | RenameChain | func (ipt *IPTables) RenameChain(table, oldChain, newChain string) error {
return ipt.run("-t", table, "-E", oldChain, newChain)
} | go | func (ipt *IPTables) RenameChain(table, oldChain, newChain string) error {
return ipt.run("-t", table, "-E", oldChain, newChain)
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"RenameChain",
"(",
"table",
",",
"oldChain",
",",
"newChain",
"string",
")",
"error",
"{",
"return",
"ipt",
".",
"run",
"(",
"\"",
"\"",
",",
"table",
",",
"\"",
"\"",
",",
"oldChain",
",",
"newChain",
")",
... | // RenameChain renames the old chain to the new one. | [
"RenameChain",
"renames",
"the",
"old",
"chain",
"to",
"the",
"new",
"one",
"."
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L330-L332 |
19,183 | coreos/go-iptables | iptables/iptables.go | DeleteChain | func (ipt *IPTables) DeleteChain(table, chain string) error {
return ipt.run("-t", table, "-X", chain)
} | go | func (ipt *IPTables) DeleteChain(table, chain string) error {
return ipt.run("-t", table, "-X", chain)
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"DeleteChain",
"(",
"table",
",",
"chain",
"string",
")",
"error",
"{",
"return",
"ipt",
".",
"run",
"(",
"\"",
"\"",
",",
"table",
",",
"\"",
"\"",
",",
"chain",
")",
"\n",
"}"
] | // DeleteChain deletes the chain in the specified table.
// The chain must be empty | [
"DeleteChain",
"deletes",
"the",
"chain",
"in",
"the",
"specified",
"table",
".",
"The",
"chain",
"must",
"be",
"empty"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L336-L338 |
19,184 | coreos/go-iptables | iptables/iptables.go | ChangePolicy | func (ipt *IPTables) ChangePolicy(table, chain, target string) error {
return ipt.run("-t", table, "-P", chain, target)
} | go | func (ipt *IPTables) ChangePolicy(table, chain, target string) error {
return ipt.run("-t", table, "-P", chain, target)
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"ChangePolicy",
"(",
"table",
",",
"chain",
",",
"target",
"string",
")",
"error",
"{",
"return",
"ipt",
".",
"run",
"(",
"\"",
"\"",
",",
"table",
",",
"\"",
"\"",
",",
"chain",
",",
"target",
")",
"\n",
... | // ChangePolicy changes policy on chain to target | [
"ChangePolicy",
"changes",
"policy",
"on",
"chain",
"to",
"target"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L341-L343 |
19,185 | coreos/go-iptables | iptables/iptables.go | GetIptablesVersion | func (ipt *IPTables) GetIptablesVersion() (int, int, int) {
return ipt.v1, ipt.v2, ipt.v3
} | go | func (ipt *IPTables) GetIptablesVersion() (int, int, int) {
return ipt.v1, ipt.v2, ipt.v3
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"GetIptablesVersion",
"(",
")",
"(",
"int",
",",
"int",
",",
"int",
")",
"{",
"return",
"ipt",
".",
"v1",
",",
"ipt",
".",
"v2",
",",
"ipt",
".",
"v3",
"\n",
"}"
] | // Return version components of the underlying iptables command | [
"Return",
"version",
"components",
"of",
"the",
"underlying",
"iptables",
"command"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L351-L353 |
19,186 | coreos/go-iptables | iptables/iptables.go | run | func (ipt *IPTables) run(args ...string) error {
return ipt.runWithOutput(args, nil)
} | go | func (ipt *IPTables) run(args ...string) error {
return ipt.runWithOutput(args, nil)
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"run",
"(",
"args",
"...",
"string",
")",
"error",
"{",
"return",
"ipt",
".",
"runWithOutput",
"(",
"args",
",",
"nil",
")",
"\n",
"}"
] | // run runs an iptables command with the given arguments, ignoring
// any stdout output | [
"run",
"runs",
"an",
"iptables",
"command",
"with",
"the",
"given",
"arguments",
"ignoring",
"any",
"stdout",
"output"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L357-L359 |
19,187 | coreos/go-iptables | iptables/iptables.go | runWithOutput | func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error {
args = append([]string{ipt.path}, args...)
if ipt.hasWait {
args = append(args, "--wait")
} else {
fmu, err := newXtablesFileLock()
if err != nil {
return err
}
ul, err := fmu.tryLock()
if err != nil {
return err
}
defer ul.Unlock()
}
var stderr bytes.Buffer
cmd := exec.Cmd{
Path: ipt.path,
Args: args,
Stdout: stdout,
Stderr: &stderr,
}
if err := cmd.Run(); err != nil {
switch e := err.(type) {
case *exec.ExitError:
return &Error{*e, cmd, stderr.String(), ipt.proto, nil}
default:
return err
}
}
return nil
} | go | func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error {
args = append([]string{ipt.path}, args...)
if ipt.hasWait {
args = append(args, "--wait")
} else {
fmu, err := newXtablesFileLock()
if err != nil {
return err
}
ul, err := fmu.tryLock()
if err != nil {
return err
}
defer ul.Unlock()
}
var stderr bytes.Buffer
cmd := exec.Cmd{
Path: ipt.path,
Args: args,
Stdout: stdout,
Stderr: &stderr,
}
if err := cmd.Run(); err != nil {
switch e := err.(type) {
case *exec.ExitError:
return &Error{*e, cmd, stderr.String(), ipt.proto, nil}
default:
return err
}
}
return nil
} | [
"func",
"(",
"ipt",
"*",
"IPTables",
")",
"runWithOutput",
"(",
"args",
"[",
"]",
"string",
",",
"stdout",
"io",
".",
"Writer",
")",
"error",
"{",
"args",
"=",
"append",
"(",
"[",
"]",
"string",
"{",
"ipt",
".",
"path",
"}",
",",
"args",
"...",
"... | // runWithOutput runs an iptables command with the given arguments,
// writing any stdout output to the given writer | [
"runWithOutput",
"runs",
"an",
"iptables",
"command",
"with",
"the",
"given",
"arguments",
"writing",
"any",
"stdout",
"output",
"to",
"the",
"given",
"writer"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L363-L397 |
19,188 | coreos/go-iptables | iptables/iptables.go | filterRuleOutput | func filterRuleOutput(rule string) string {
out := rule
// work around an output difference in nftables mode where counters
// are output in iptables-save format, rather than iptables -S format
// The string begins with "[0:0]"
//
// Fixes #49
if groups := counterRegex.FindStringSubmatch(out); groups != nil {
// drop the brackets
out = out[len(groups[0]):]
out = fmt.Sprintf("%s -c %s %s", out, groups[1], groups[2])
}
return out
} | go | func filterRuleOutput(rule string) string {
out := rule
// work around an output difference in nftables mode where counters
// are output in iptables-save format, rather than iptables -S format
// The string begins with "[0:0]"
//
// Fixes #49
if groups := counterRegex.FindStringSubmatch(out); groups != nil {
// drop the brackets
out = out[len(groups[0]):]
out = fmt.Sprintf("%s -c %s %s", out, groups[1], groups[2])
}
return out
} | [
"func",
"filterRuleOutput",
"(",
"rule",
"string",
")",
"string",
"{",
"out",
":=",
"rule",
"\n\n",
"// work around an output difference in nftables mode where counters",
"// are output in iptables-save format, rather than iptables -S format",
"// The string begins with \"[0:0]\"",
"//... | // filterRuleOutput works around some inconsistencies in output.
// For example, when iptables is in legacy vs. nftables mode, it produces
// different results. | [
"filterRuleOutput",
"works",
"around",
"some",
"inconsistencies",
"in",
"output",
".",
"For",
"example",
"when",
"iptables",
"is",
"in",
"legacy",
"vs",
".",
"nftables",
"mode",
"it",
"produces",
"different",
"results",
"."
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/iptables.go#L517-L532 |
19,189 | coreos/go-iptables | iptables/lock.go | Unlock | func (l *fileLock) Unlock() error {
defer l.mu.Unlock()
return syscall.Close(l.fd)
} | go | func (l *fileLock) Unlock() error {
defer l.mu.Unlock()
return syscall.Close(l.fd)
} | [
"func",
"(",
"l",
"*",
"fileLock",
")",
"Unlock",
"(",
")",
"error",
"{",
"defer",
"l",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"syscall",
".",
"Close",
"(",
"l",
".",
"fd",
")",
"\n",
"}"
] | // Unlock closes the underlying file, which implicitly unlocks it as well. It
// also unlocks the associated mutex. | [
"Unlock",
"closes",
"the",
"underlying",
"file",
"which",
"implicitly",
"unlocks",
"it",
"as",
"well",
".",
"It",
"also",
"unlocks",
"the",
"associated",
"mutex",
"."
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/lock.go#L71-L74 |
19,190 | coreos/go-iptables | iptables/lock.go | newXtablesFileLock | func newXtablesFileLock() (*fileLock, error) {
fd, err := syscall.Open(xtablesLockFilePath, os.O_CREATE, defaultFilePerm)
if err != nil {
return nil, err
}
return &fileLock{fd: fd}, nil
} | go | func newXtablesFileLock() (*fileLock, error) {
fd, err := syscall.Open(xtablesLockFilePath, os.O_CREATE, defaultFilePerm)
if err != nil {
return nil, err
}
return &fileLock{fd: fd}, nil
} | [
"func",
"newXtablesFileLock",
"(",
")",
"(",
"*",
"fileLock",
",",
"error",
")",
"{",
"fd",
",",
"err",
":=",
"syscall",
".",
"Open",
"(",
"xtablesLockFilePath",
",",
"os",
".",
"O_CREATE",
",",
"defaultFilePerm",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // newXtablesFileLock opens a new lock on the xtables lockfile without
// acquiring the lock | [
"newXtablesFileLock",
"opens",
"a",
"new",
"lock",
"on",
"the",
"xtables",
"lockfile",
"without",
"acquiring",
"the",
"lock"
] | 78b5fff24e6df8886ef8eca9411f683a884349a5 | https://github.com/coreos/go-iptables/blob/78b5fff24e6df8886ef8eca9411f683a884349a5/iptables/lock.go#L78-L84 |
19,191 | edsrzf/mmap-go | mmap.go | Map | func Map(f *os.File, prot, flags int) (MMap, error) {
return MapRegion(f, -1, prot, flags, 0)
} | go | func Map(f *os.File, prot, flags int) (MMap, error) {
return MapRegion(f, -1, prot, flags, 0)
} | [
"func",
"Map",
"(",
"f",
"*",
"os",
".",
"File",
",",
"prot",
",",
"flags",
"int",
")",
"(",
"MMap",
",",
"error",
")",
"{",
"return",
"MapRegion",
"(",
"f",
",",
"-",
"1",
",",
"prot",
",",
"flags",
",",
"0",
")",
"\n",
"}"
] | // Map maps an entire file into memory.
// If ANON is set in flags, f is ignored. | [
"Map",
"maps",
"an",
"entire",
"file",
"into",
"memory",
".",
"If",
"ANON",
"is",
"set",
"in",
"flags",
"f",
"is",
"ignored",
"."
] | 904c4ced31cdffe19e971afa0b3d319ff06d9c72 | https://github.com/edsrzf/mmap-go/blob/904c4ced31cdffe19e971afa0b3d319ff06d9c72/mmap.go#L48-L50 |
19,192 | edsrzf/mmap-go | mmap.go | MapRegion | func MapRegion(f *os.File, length int, prot, flags int, offset int64) (MMap, error) {
if offset%int64(os.Getpagesize()) != 0 {
return nil, errors.New("offset parameter must be a multiple of the system's page size")
}
var fd uintptr
if flags&ANON == 0 {
fd = uintptr(f.Fd())
if length < 0 {
fi, err := f.Stat()
if err != nil {
return nil, err
}
length = int(fi.Size())
}
} else {
if length <= 0 {
return nil, errors.New("anonymous mapping requires non-zero length")
}
fd = ^uintptr(0)
}
return mmap(length, uintptr(prot), uintptr(flags), fd, offset)
} | go | func MapRegion(f *os.File, length int, prot, flags int, offset int64) (MMap, error) {
if offset%int64(os.Getpagesize()) != 0 {
return nil, errors.New("offset parameter must be a multiple of the system's page size")
}
var fd uintptr
if flags&ANON == 0 {
fd = uintptr(f.Fd())
if length < 0 {
fi, err := f.Stat()
if err != nil {
return nil, err
}
length = int(fi.Size())
}
} else {
if length <= 0 {
return nil, errors.New("anonymous mapping requires non-zero length")
}
fd = ^uintptr(0)
}
return mmap(length, uintptr(prot), uintptr(flags), fd, offset)
} | [
"func",
"MapRegion",
"(",
"f",
"*",
"os",
".",
"File",
",",
"length",
"int",
",",
"prot",
",",
"flags",
"int",
",",
"offset",
"int64",
")",
"(",
"MMap",
",",
"error",
")",
"{",
"if",
"offset",
"%",
"int64",
"(",
"os",
".",
"Getpagesize",
"(",
")"... | // MapRegion maps part of a file into memory.
// The offset parameter must be a multiple of the system's page size.
// If length < 0, the entire file will be mapped.
// If ANON is set in flags, f is ignored. | [
"MapRegion",
"maps",
"part",
"of",
"a",
"file",
"into",
"memory",
".",
"The",
"offset",
"parameter",
"must",
"be",
"a",
"multiple",
"of",
"the",
"system",
"s",
"page",
"size",
".",
"If",
"length",
"<",
"0",
"the",
"entire",
"file",
"will",
"be",
"mappe... | 904c4ced31cdffe19e971afa0b3d319ff06d9c72 | https://github.com/edsrzf/mmap-go/blob/904c4ced31cdffe19e971afa0b3d319ff06d9c72/mmap.go#L56-L78 |
19,193 | matrix-org/gomatrix | events.go | Body | func (event *Event) Body() (body string, ok bool) {
value, exists := event.Content["body"]
if !exists {
return
}
body, ok = value.(string)
return
} | go | func (event *Event) Body() (body string, ok bool) {
value, exists := event.Content["body"]
if !exists {
return
}
body, ok = value.(string)
return
} | [
"func",
"(",
"event",
"*",
"Event",
")",
"Body",
"(",
")",
"(",
"body",
"string",
",",
"ok",
"bool",
")",
"{",
"value",
",",
"exists",
":=",
"event",
".",
"Content",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"exists",
"{",
"return",
"\n",
"}",
"\n... | // Body returns the value of the "body" key in the event content if it is
// present and is a string. | [
"Body",
"returns",
"the",
"value",
"of",
"the",
"body",
"key",
"in",
"the",
"event",
"content",
"if",
"it",
"is",
"present",
"and",
"is",
"a",
"string",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/events.go#L23-L30 |
19,194 | matrix-org/gomatrix | events.go | MessageType | func (event *Event) MessageType() (msgtype string, ok bool) {
value, exists := event.Content["msgtype"]
if !exists {
return
}
msgtype, ok = value.(string)
return
} | go | func (event *Event) MessageType() (msgtype string, ok bool) {
value, exists := event.Content["msgtype"]
if !exists {
return
}
msgtype, ok = value.(string)
return
} | [
"func",
"(",
"event",
"*",
"Event",
")",
"MessageType",
"(",
")",
"(",
"msgtype",
"string",
",",
"ok",
"bool",
")",
"{",
"value",
",",
"exists",
":=",
"event",
".",
"Content",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"exists",
"{",
"return",
"\n",
... | // MessageType returns the value of the "msgtype" key in the event content if
// it is present and is a string. | [
"MessageType",
"returns",
"the",
"value",
"of",
"the",
"msgtype",
"key",
"in",
"the",
"event",
"content",
"if",
"it",
"is",
"present",
"and",
"is",
"a",
"string",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/events.go#L34-L41 |
19,195 | matrix-org/gomatrix | events.go | GetHTMLMessage | func GetHTMLMessage(msgtype, htmlText string) HTMLMessage {
return HTMLMessage{
Body: html.UnescapeString(htmlRegex.ReplaceAllLiteralString(htmlText, "")),
MsgType: msgtype,
Format: "org.matrix.custom.html",
FormattedBody: htmlText,
}
} | go | func GetHTMLMessage(msgtype, htmlText string) HTMLMessage {
return HTMLMessage{
Body: html.UnescapeString(htmlRegex.ReplaceAllLiteralString(htmlText, "")),
MsgType: msgtype,
Format: "org.matrix.custom.html",
FormattedBody: htmlText,
}
} | [
"func",
"GetHTMLMessage",
"(",
"msgtype",
",",
"htmlText",
"string",
")",
"HTMLMessage",
"{",
"return",
"HTMLMessage",
"{",
"Body",
":",
"html",
".",
"UnescapeString",
"(",
"htmlRegex",
".",
"ReplaceAllLiteralString",
"(",
"htmlText",
",",
"\"",
"\"",
")",
")"... | // GetHTMLMessage returns an HTMLMessage with the body set to a stripped version of the provided HTML, in addition
// to the provided HTML. | [
"GetHTMLMessage",
"returns",
"an",
"HTMLMessage",
"with",
"the",
"body",
"set",
"to",
"a",
"stripped",
"version",
"of",
"the",
"provided",
"HTML",
"in",
"addition",
"to",
"the",
"provided",
"HTML",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/events.go#L106-L113 |
19,196 | matrix-org/gomatrix | room.go | GetMembershipState | func (room Room) GetMembershipState(userID string) string {
state := "leave"
event := room.GetStateEvent("m.room.member", userID)
if event != nil {
membershipState, found := event.Content["membership"]
if found {
mState, isString := membershipState.(string)
if isString {
state = mState
}
}
}
return state
} | go | func (room Room) GetMembershipState(userID string) string {
state := "leave"
event := room.GetStateEvent("m.room.member", userID)
if event != nil {
membershipState, found := event.Content["membership"]
if found {
mState, isString := membershipState.(string)
if isString {
state = mState
}
}
}
return state
} | [
"func",
"(",
"room",
"Room",
")",
"GetMembershipState",
"(",
"userID",
"string",
")",
"string",
"{",
"state",
":=",
"\"",
"\"",
"\n",
"event",
":=",
"room",
".",
"GetStateEvent",
"(",
"\"",
"\"",
",",
"userID",
")",
"\n",
"if",
"event",
"!=",
"nil",
... | // GetMembershipState returns the membership state of the given user ID in this room. If there is
// no entry for this member, 'leave' is returned for consistency with left users. | [
"GetMembershipState",
"returns",
"the",
"membership",
"state",
"of",
"the",
"given",
"user",
"ID",
"in",
"this",
"room",
".",
"If",
"there",
"is",
"no",
"entry",
"for",
"this",
"member",
"leave",
"is",
"returned",
"for",
"consistency",
"with",
"left",
"users... | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/room.go#L28-L41 |
19,197 | matrix-org/gomatrix | room.go | NewRoom | func NewRoom(roomID string) *Room {
// Init the State map and return a pointer to the Room
return &Room{
ID: roomID,
State: make(map[string]map[string]*Event),
}
} | go | func NewRoom(roomID string) *Room {
// Init the State map and return a pointer to the Room
return &Room{
ID: roomID,
State: make(map[string]map[string]*Event),
}
} | [
"func",
"NewRoom",
"(",
"roomID",
"string",
")",
"*",
"Room",
"{",
"// Init the State map and return a pointer to the Room",
"return",
"&",
"Room",
"{",
"ID",
":",
"roomID",
",",
"State",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]"... | // NewRoom creates a new Room with the given ID | [
"NewRoom",
"creates",
"a",
"new",
"Room",
"with",
"the",
"given",
"ID"
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/room.go#L44-L50 |
19,198 | matrix-org/gomatrix | responses.go | HasSingleStageFlow | func (r RespUserInteractive) HasSingleStageFlow(stageName string) bool {
for _, f := range r.Flows {
if len(f.Stages) == 1 && f.Stages[0] == stageName {
return true
}
}
return false
} | go | func (r RespUserInteractive) HasSingleStageFlow(stageName string) bool {
for _, f := range r.Flows {
if len(f.Stages) == 1 && f.Stages[0] == stageName {
return true
}
}
return false
} | [
"func",
"(",
"r",
"RespUserInteractive",
")",
"HasSingleStageFlow",
"(",
"stageName",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"r",
".",
"Flows",
"{",
"if",
"len",
"(",
"f",
".",
"Stages",
")",
"==",
"1",
"&&",
"f",
".",
"St... | // HasSingleStageFlow returns true if there exists at least 1 Flow with a single stage of stageName. | [
"HasSingleStageFlow",
"returns",
"true",
"if",
"there",
"exists",
"at",
"least",
"1",
"Flow",
"with",
"a",
"single",
"stage",
"of",
"stageName",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/responses.go#L94-L101 |
19,199 | matrix-org/gomatrix | client.go | SetCredentials | func (cli *Client) SetCredentials(userID, accessToken string) {
cli.AccessToken = accessToken
cli.UserID = userID
} | go | func (cli *Client) SetCredentials(userID, accessToken string) {
cli.AccessToken = accessToken
cli.UserID = userID
} | [
"func",
"(",
"cli",
"*",
"Client",
")",
"SetCredentials",
"(",
"userID",
",",
"accessToken",
"string",
")",
"{",
"cli",
".",
"AccessToken",
"=",
"accessToken",
"\n",
"cli",
".",
"UserID",
"=",
"userID",
"\n",
"}"
] | // SetCredentials sets the user ID and access token on this client instance. | [
"SetCredentials",
"sets",
"the",
"user",
"ID",
"and",
"access",
"token",
"on",
"this",
"client",
"instance",
"."
] | 0c31efc5dc7385fa91705093d77bfc554c2751f9 | https://github.com/matrix-org/gomatrix/blob/0c31efc5dc7385fa91705093d77bfc554c2751f9/client.go#L99-L102 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.