// DecodeVarint decodes the varint from the Reader.
483404
func DecodeVarint(in io.Reader) (int, error) {
	u, err := DecodeUvarint(in)
	n := int(u)
	return (n >> 1) ^ -(n & 1), err
}
1194705
func (d Decoder) Decode(dst interface{}) error {
	bs, err := ioutil.ReadAll(d.r)
	if err != nil {
		return err
	}
	vs, err := url.ParseQuery(string(bs))
	if err != nil {
		return err
	}
	v := reflect.ValueOf(dst)
	return d.decodeNode(v, parseValues(d.d, d.e, vs, canIndexOrdinally(v)))
}
88846
func (d *Decoder) Decode(v interface{}) error {
	b, err := ioutil.ReadAll(d.r)
	if err != nil {
		return err
	}
	return d.cfg.Unmarshal(b, v)
}
881337
func (d *Decoder) Decode(v interface{}) error {
	var err error
	d.tval, err = LoadReader(d.r)
	if err != nil {
		return err
	}
	return d.unmarshal(v)
}
518732
func DecoderFor(r io.Reader) Decoder {
	var buf bytes.Buffer
	for _, dec := range []DecoderFactory{
		NewDecoder,
		NewJSONDecoder,
		NewCSVDecoder,
	} {
		rd := io.MultiReader(bytes.NewReader(buf.Bytes()), io.TeeReader(r, &buf))
		if err := dec(rd).Decode(&Result{}); err == nil {
			return dec(io.MultiReader(&buf, r))
		}
	}
	return nil
}
892511
func (c *UpdateAddHTLC) Decode(r io.Reader, pver uint32) error {
	return ReadElements(r,
		&c.ChanID,
		&c.ID,
		&c.Amount,
		c.PaymentHash[:],
		&c.Expiry,
		c.OnionBlob[:],
	)
}
846339
func decodeValue(dv, sv reflect.Value, blank bool) error {
	return valueDecoder(dv, sv, blank)(dv, sv)
}
659920
func NewDecoder(r io.Reader, format Format) Decoder {
	switch format {
	case FmtProtoDelim:
		return &protoDecoder{r: r}
	}
	return &textDecoder{r: r}
}
765904
func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) {
	gd = genHelperDecoder{d: d}
	dd = genHelperDecDriver{decDriver: d.d}
	return
}
330157
func NewDecoder(r io.Reader, h Handle) *Decoder {
	d := newDecoder(h)
	d.Reset(r)
	return d
}
240229
func readVarInt(r io.Reader) (uint64, int, error) {
	var b [8]byte
	_, err := io.ReadFull(r, b[0:1])
	if err != nil {
		return 0, 1, err
	}

	var rv uint64
	var n int // number of bytes
	discriminant := uint8(b[0])
	switch discriminant {
	case 0xff:
		n = 9
		_, err := io.ReadFull(r, b[:])
		if err != nil {
			return 0, n, err
		}
		rv = binary.LittleEndian.Uint64(b[:])

		// The encoding is not canonical if the value could have been
		// encoded using fewer bytes
		min := uint64(0x100000000)
		if rv < min {
			return 0, n, fmt.Errorf("readVarInt: %d, %d, %d", rv, discriminant, min)
		}

	case 0xfe:
		n = 5
		_, err := io.ReadFull(r, b[0:4])
		if err != nil {
			return 0, n, err
		}
		rv = uint64(binary.LittleEndian.Uint32(b[:]))

		// The encoding is not canonical if the value could have been
		// encoded using fewer bytes
		min := uint64(0x10000)
		if rv < min {
			return 0, n, fmt.Errorf("readVarInt: %d, %d, %d", rv, discriminant, min)
		}

	case 0xfd:
		n = 3
		_, err := io.ReadFull(r, b[0:2])
		if err != nil {
			return 0, n, err
		}
		rv = uint64(binary.LittleEndian.Uint16(b[:]))

		// The encoding is not canonical if the value could have been
		// encoded using fewer bytes
		min := uint64(0xfd)
		if rv < min {
			return 0, n, fmt.Errorf("readVarInt: %d, %d, %d", rv, discriminant, min)
		}

	default:
		rv = uint64(discriminant)
		n = 1
	}

	return rv, n, nil
}
537589
func decodeValue(rawKV interface{}) error {
	rawMap, ok := rawKV.(map[string]interface{})
	if !ok {
		return fmt.Errorf("unexpected raw KV type: %T", rawKV)
	}
	for k, v := range rawMap {
		switch strings.ToLower(k) {
		case "value":
			// Leave the byte slice nil if we have a nil
			// value.
			if v == nil {
				return nil
			}

			// Otherwise, base64 decode it.
			s, ok := v.(string)
			if !ok {
				return fmt.Errorf("unexpected value type: %T", v)
			}
			decoded, err := base64.StdEncoding.DecodeString(s)
			if err != nil {
				return fmt.Errorf("failed to decode value: %v", err)
			}
			rawMap[k] = decoded
			return nil
		}
	}
	return nil
}
686621
func NewDecoder(r io.Reader) *Decoder {
	d := &Decoder{
		ns:       make(map[string]string),
		nextByte: -1,
		line:     1,
		Strict:   true,
	}
	d.switchToReader(r)
	return d
}
1322538
func NewDecoder(r io.Reader, plugins ...plugin) *Decoder {
	d := &Decoder{r: r, contentPrefix: contentPrefix, attributePrefix: attrPrefix, excludeAttrs: map[string]bool{}}
	for _, p := range plugins {
		d = p.AddToDecoder(d)
	}
	return d
}
665629
func NewDecoder(r io.Reader) *decoder {
	d := &decoder{
		scanner:  bufio.NewScanner(r),
		nextFn:   decodeInit,
		line:     0,
		buffered: "",
	}
	return d
}
354805
func NewDecoder(r io.Reader) *Decoder {
	return &Decoder{
		dec: codec.NewDecoder(r, new(codec.CborHandle)),
	}
}
28833
func (c *Client) DecodeError(resp *http.Response, requestMethod string) error {
	err := &errors.APIError{
		StatusCode: resp.StatusCode,
	}

	if requestMethod != http.MethodHead && resp.Body != nil {
		errorDecoder := json.NewDecoder(resp.Body)
		if err := errorDecoder.Decode(err); err != nil {
			return pkgerrors.Wrapf(err, "unable to decode error response")
		}
	}

	if err.Message == "" {
		err.Message = fmt.Sprintf("HTTP response returned status code %d", err.StatusCode)
	}

	return err
}