(iv interface{})
| 1162 | } |
| 1163 | |
| 1164 | func (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: |
no test coverage detected