We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent db22191 commit fa9bf37Copy full SHA for fa9bf37
1 file changed
internal/cbor/types.go
@@ -4,6 +4,7 @@ import (
4
"fmt"
5
"math"
6
"net"
7
+ "reflect"
8
)
9
10
// AppendNil inserts a 'Nil' object into the dst byte array.
@@ -438,6 +439,14 @@ func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte {
438
439
return AppendEmbeddedJSON(dst, marshaled)
440
}
441
442
+// AppendType appends the parameter type (as a string) to the input byte slice.
443
+func (e Encoder) AppendType(dst []byte, i interface{}) []byte {
444
+ if i == nil {
445
+ return e.AppendString(dst, "<nil>")
446
+ }
447
+ return e.AppendString(dst, reflect.TypeOf(i).String())
448
+}
449
+
450
// AppendIPAddr encodes and inserts an IP Address (IPv4 or IPv6).
451
func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte {
452
dst = append(dst, majorTypeTags|additionalTypeIntUint16)
0 commit comments