MCPcopy
hub / github.com/ugorji/go / encode

Method encode

codec/encode.go:1164–1275  ·  view source on GitHub ↗
(iv interface{})

Source from the content-addressed store, hash-verified

1162}
1163
1164func (e *Encoder) encode(iv interface{}) {
1165 // MARKER: a switch with only concrete types can be optimized.
1166 // consequently, we deal with nil and interfaces outside the switch.
1167
1168 if iv == nil {
1169 e.e.EncodeNil()
1170 return
1171 }
1172
1173 rv, ok := isNil(iv)
1174 if ok {
1175 e.e.EncodeNil()
1176 return
1177 }
1178
1179 switch v := iv.(type) {
1180 // case nil:
1181 // case Selfer:
1182 case Raw:
1183 e.rawBytes(v)
1184 case reflect.Value:
1185 e.encodeValue(v, nil)
1186
1187 case string:
1188 e.e.EncodeString(v)
1189 case bool:
1190 e.e.EncodeBool(v)
1191 case int:
1192 e.e.EncodeInt(int64(v))
1193 case int8:
1194 e.e.EncodeInt(int64(v))
1195 case int16:
1196 e.e.EncodeInt(int64(v))
1197 case int32:
1198 e.e.EncodeInt(int64(v))
1199 case int64:
1200 e.e.EncodeInt(v)
1201 case uint:
1202 e.e.EncodeUint(uint64(v))
1203 case uint8:
1204 e.e.EncodeUint(uint64(v))
1205 case uint16:
1206 e.e.EncodeUint(uint64(v))
1207 case uint32:
1208 e.e.EncodeUint(uint64(v))
1209 case uint64:
1210 e.e.EncodeUint(v)
1211 case uintptr:
1212 e.e.EncodeUint(uint64(v))
1213 case float32:
1214 e.e.EncodeFloat32(v)
1215 case float64:
1216 e.e.EncodeFloat64(v)
1217 case complex64:
1218 e.encodeComplex64(v)
1219 case complex128:
1220 e.encodeComplex128(v)
1221 case time.Time:

Callers 15

kStructMethod · 0.95
MustEncodeMethod · 0.95
EncEncodeMethod · 0.80
EncSliceIntfVMethod · 0.80
EncAsMapSliceIntfVMethod · 0.80
EncMapStringIntfVMethod · 0.80
EncMapUint8IntfVMethod · 0.80
EncMapUint64IntfVMethod · 0.80
EncMapIntIntfVMethod · 0.80
EncMapInt32IntfVMethod · 0.80
EncodeExtMethod · 0.80
EncodeRawExtMethod · 0.80

Calls 15

rawBytesMethod · 0.95
encodeValueMethod · 0.95
encodeComplex64Method · 0.95
encodeComplex128Method · 0.95
isNilFunction · 0.70
fastpathEncodeTypeSwitchFunction · 0.70
EncodeNilMethod · 0.65
EncodeStringMethod · 0.65
EncodeBoolMethod · 0.65
EncodeIntMethod · 0.65
EncodeUintMethod · 0.65
EncodeFloat32Method · 0.65

Tested by

no test coverage detected