Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape field tags #379

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _generated/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type X struct {
Others [][32]int32 // should compile to len(x.Others)*32*msgp.Int32Size
Matrix [][]int32 // should not optimize
ManyFixed []Fixed
WeirdTag string `msg:"\x0b"`
}

// test fixed-size struct
Expand Down
2 changes: 1 addition & 1 deletion gen/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (d *decodeGen) structAsMap(s *Struct) {
d.p.print("\nswitch msgp.UnsafeString(field) {")
for i := range s.Fields {
d.ctx.PushString(s.Fields[i].FieldName)
d.p.printf("\ncase \"%s\":", s.Fields[i].FieldTag)
d.p.printf("\ncase %q:", s.Fields[i].FieldTag)
fieldElem := s.Fields[i].FieldElem
anField := s.Fields[i].HasTagPart("allownil") && fieldElem.AllowNil()
if anField {
Expand Down
2 changes: 1 addition & 1 deletion gen/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (u *unmarshalGen) mapstruct(s *Struct) {
if !u.p.ok() {
return
}
u.p.printf("\ncase \"%s\":", s.Fields[i].FieldTag)
u.p.printf("\ncase %q:", s.Fields[i].FieldTag)
u.ctx.PushString(s.Fields[i].FieldName)

fieldElem := s.Fields[i].FieldElem
Expand Down
Loading