Fix missing cbor encoder AppendType method
This commit is contained in:
parent
db22191211
commit
fa9bf3742a
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppendNil inserts a 'Nil' object into the dst byte array.
|
// AppendNil inserts a 'Nil' object into the dst byte array.
|
||||||
|
@ -438,6 +439,14 @@ func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte {
|
||||||
return AppendEmbeddedJSON(dst, marshaled)
|
return AppendEmbeddedJSON(dst, marshaled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AppendType appends the parameter type (as a string) to the input byte slice.
|
||||||
|
func (e Encoder) AppendType(dst []byte, i interface{}) []byte {
|
||||||
|
if i == nil {
|
||||||
|
return e.AppendString(dst, "<nil>")
|
||||||
|
}
|
||||||
|
return e.AppendString(dst, reflect.TypeOf(i).String())
|
||||||
|
}
|
||||||
|
|
||||||
// AppendIPAddr encodes and inserts an IP Address (IPv4 or IPv6).
|
// AppendIPAddr encodes and inserts an IP Address (IPv4 or IPv6).
|
||||||
func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte {
|
func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte {
|
||||||
dst = append(dst, majorTypeTags|additionalTypeIntUint16)
|
dst = append(dst, majorTypeTags|additionalTypeIntUint16)
|
||||||
|
|
Loading…
Reference in New Issue