Skip to content

feat(golang): support field_mask in slim struct template - #313

Open
AdamMagued wants to merge 1 commit into
cloudwego:mainfrom
AdamMagued:feat-issue-312-slim-fieldmask
Open

AdamMagued wants to merge 1 commit into
cloudwego:mainfrom
AdamMagued:feat-issue-312-slim-fieldmask

Conversation

@AdamMagued

Copy link
Copy Markdown

Fixes #312

Problem

When with_field_mask is enabled, the slim template (template=slim and no_default_serdes) does not inject the _fieldmask field or its getter/setter methods (Get_FieldMask, Set_FieldMask, Pass_FieldMask) into generated structs. Fast codec generators and reflection callers require _fieldmask on the struct, which causes compilation errors when using the slim template.

Solution

  1. In generator/golang/templates/slim/slim.go, inject _fieldmask *fieldmask.FieldMask into StructLike and import fieldmask when Features.WithFieldMask is active.
  2. Add Get_FieldMask, Set_FieldMask, and Pass_FieldMask methods to StructLike in slim.go.
  3. In generator/golang/templates/raw_struct/raw_struct.go, inject _fieldmask *fieldmask.FieldMask when Features.WithFieldMask is active.
  4. Add unit tests in generator/golang/fieldmask_slim_test.go covering template=slim, no_default_serdes, and template=raw_struct with with_field_mask and field_mask_halfway, verifying struct definitions and Go compilation.
  5. Add test matrix cases to tests/options/run.sh.

@AdamMagued
AdamMagued requested a review from a team as a code owner October 10, 2026 21:56
@CLAassistant

CLAassistant commented Oct 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

slim template support field_mask

2 participants