WriteInt16 write the int16 with the tag.
(data int16, tag byte)
| 223 | |
| 224 | // WriteInt16 write the int16 with the tag. |
| 225 | func (b *Buffer) WriteInt16(data int16, tag byte) error { |
| 226 | var err error |
| 227 | if data >= math.MinInt8 && data <= math.MaxInt8 { |
| 228 | if err = b.WriteInt8(int8(data), tag); err != nil { |
| 229 | return err |
| 230 | } |
| 231 | } else { |
| 232 | if err = b.WriteHead(SHORT, tag); err != nil { |
| 233 | return err |
| 234 | } |
| 235 | |
| 236 | if err = bWriteU16(b.buf, uint16(data)); err != nil { |
| 237 | return err |
| 238 | } |
| 239 | } |
| 240 | return nil |
| 241 | } |
| 242 | |
| 243 | // WriteUint16 write uint16 with the tag. |
| 244 | func (b *Buffer) WriteUint16(data uint16, tag byte) error { |