Skip to content

Commit

Permalink
Also set for primitives.
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost committed Oct 22, 2024
1 parent 0d4a0f3 commit ed93ec2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _generated/allownil.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,6 @@ type AllowNilOmitEmpty2 struct {
Field00 []string `msg:"field00,allownil,omitempty"`
Field01 []string `msg:"field01,allownil,omitempty"`
}

// Primitive types cannot have allownil for now.
type NoAllowNil []byte
1 change: 1 addition & 0 deletions gen/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (p *Printer) ApplyDirective(pass Method, t TransformPass) {

// Print prints an Elem.
func (p *Printer) Print(e Elem) error {
e.SetIsAllowNil(false)
for _, g := range p.gens {
// Elem.SetVarname() is called before the Print() step in parse.FileSet.PrintTo().
// Elem.SetVarname() generates identifiers as it walks the Elem. This can cause
Expand Down

0 comments on commit ed93ec2

Please sign in to comment.