yeqown / protoc-gen-fieldmask

Generate FieldMask utility functions for protobuf
MIT License
34 stars 9 forks source link

Allow one of .in or .out option to be skipped #4

Closed vaidasn closed 2 years ago

vaidasn commented 2 years ago

Fixes #3

yeqown commented 2 years ago

modify fm_message_in.go#L45 maybe better, construct opt(pbfieldmask.FieldMask) to make sure In and Out has been initialized.

        opt := &pbfieldmask.FieldMask{
            In:  new(pbfieldmask.InMessageOption),
            Out: new(pbfieldmask.OutMessageOption),
        }
vaidasn commented 2 years ago

modify fm_message_in.go#L45 maybe better, construct opt(pbfieldmask.FieldMask) to make sure In and Out has been initialized.

      opt := &pbfieldmask.FieldMask{
          In:  new(pbfieldmask.InMessageOption),
          Out: new(pbfieldmask.OutMessageOption),
      }

Your proposed fix doesn’t help, I’m still getting the error:

[error] unable to convert user.pb.fm.go to proto: template: go:12:22: executing "go" at <$pair.FieldMaskOption.In.Gen>: nil pointer evaluating *fieldmask.InMessageOption.Gen

However there is no error with my PR.

yeqown commented 2 years ago

fine, give me try

yeqown commented 2 years ago

I see,

ok, err := f.Extension(pbfieldmask.E_Option, &opt)

This function would overwrite opt, so the initialization would lose efficacy.