reflect: make sure null bytes are supported in tags

This commit is contained in:
Ayke van Laethem
2023-01-10 18:41:00 +01:00
committed by Ron Evans
parent 012bdfae80
commit ebb410afd9
2 changed files with 19 additions and 18 deletions
+4 -3
View File
@@ -3,6 +3,7 @@ package main
import (
"errors"
"reflect"
"strconv"
"unsafe"
)
@@ -17,8 +18,8 @@ type (
Y int16
}
mystruct struct {
n int `foo:"bar"`
some point
n int `foo:"bar"`
some point "some\x00tag"
zero struct{}
buf []byte
Buf []byte
@@ -480,7 +481,7 @@ func showValue(rv reflect.Value, indent string) {
for i := 0; i < rv.NumField(); i++ {
field := rt.Field(i)
println(indent+" field:", i, field.Name)
println(indent+" tag:", field.Tag)
println(indent+" tag:", strconv.Quote(string(field.Tag)))
println(indent+" embedded:", field.Anonymous)
println(indent+" exported:", field.IsExported())
showValue(rv.Field(i), indent+" ")