-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
What version of Go are you using (go version
)?
$ go version go version go1.14.1 windows/amd64
Does this issue reproduce with the latest release?
Yes, it reproduces with the latest release.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env set GO111MODULE=on set GOARCH=amd64 set GOBIN= set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GONOPROXY= set GONOSUMDB= set GOOS=windows
What did you do?
My struct has a string
field with a json:"string"
field tag. When this field contains escaped character, I get unexcepted result when doing roundtrip test.
type T struct {
F1 string `json:"F1,string"`
}
t := T {
"aaa\tbbb",
}
b, _ := json.Marshal(t)
if err := json.Unmarshal(b, &t); err == nil {
fmt.Printf("%+v\n", t)
}else {
fmt.Println(err)
}
What did you expect to see?
{F1:aaa bbb}
What did you see instead?
json: invalid use of ,string struct tag, trying to unmarshal "\"aaa\tbbb\"" into string