func (p *Parser) parseUint16() uint16 {
	return binary.BigEndian.Uint16(p.read(2))
}
Read two bytes from the internal
buffer and returns it back as uint16
package cbor
import (
	"encoding/binary"
	"fmt"
	"io"
	"math"
)
type ParserErr struct {
	Msg string
}
func (pe ParserErr) Error() string {
	return pe.Msg
}
func NewParseErr(msg string) ParserErr {
	return ParserErr{msg}
}
type Parser struct {
	header     byte
	r          io.Reader
	indefinite bool
	buf        []byte
	off        int  
}
func NewParser(r io.Reader) *Parser {
	return &Parser{r: r}
}
func (p *Parser) isBreak() bool {
	return p.header == cborBreak
}
func (p *Parser) isNil() bool {
	return p.header == absoluteNil
}
func (p *Parser) isUndef() bool {
	return p.header == absoluteUndef
}
func (p *Parser) parseInformation() (major Major, info byte, err error) {
	p.header, err = p.scan1()
	if err != nil {
		return 0, 0, err
	}
	major, infotype := p.parseHeader()
	if infotype <= cborSmallInt {
		p.buf = []byte{infotype}
		return major, infotype, nil
	}
	if infotype == cborIndefinite {
		if major < cborByteString || major > cborDataMap && major != cborNC {
			return major, info, NewParseErr(fmt.Sprintf(
				"received additional info 31 (indefinite) for wrong major %d\n", major))
		}
		p.indefinite = true
		return major, infotype, nil
	}
	if (infotype >= 28 && infotype <= 30) || infotype > 31 {
		return major, info, NewParseErr(
			fmt.Sprintf("invalid additional info %d", infotype))
	}
	bytes := 1 << uint(3-(0x1b-uint(infotype)))
	_, p.buf, err = p.scan(bytes)
	return major, infotype, err
}
func (p *Parser) parseHeader() (Major, byte) {
	return Major(p.header >> 5), p.header & 0x1f
}
func (p *Parser) buflen() uint64 {
	var v uint64
	info := p.header & 0x1f
	if info <= cborSmallInt {
		v = uint64(info)
	} else {
		switch len(p.buf) {
		case 1:
			v = uint64(p.parseUint8())
		case 2:
			v = uint64(p.parseUint16())
		case 4:
			v = uint64(p.parseUint32())
		case 8:
			v = uint64(p.parseUint64())
		}
	}
	return v
}
func (p *Parser) read(n int) []byte {
	a := (len(p.buf) - p.off)
	if n > a {
		panic(fmt.Sprintf(
			"can't read %d bytes from buffer as only %d are available\n", n, a))
	}
	oldOff := p.off
	p.off += n
	return p.buf[oldOff:p.off]
}
func (p *Parser) scan(n int) (numbytes int, data []byte, err error) {
	if n <= 0 {
		return
	}
	data = make([]byte, n)
	if numbytes, err = p.r.Read(data); err != nil {
		return 0, nil, err
	}
	if numbytes < n {
		return 0, nil, NewParseErr(fmt.Sprintf(
			"can't scan %d bytes from buffer as only %d are available\n", n, numbytes))
	}
	p.off = 0
	return numbytes, data, nil
}
func (p *Parser) scan1() (byte, error) {
	_, tmpdata, err := p.scan(1)
	if err != nil {
		return 0, err
	}
	return tmpdata[0], nil
}
func (p *Parser) parseUint8() uint8 {
	return uint8(p.read(1)[0])
}