Skip to content

The generated marshallers ignore the omitzero tag #426

Description

@gnvk

The "omitzero" JSON tag has been introduced in Go 1.24. However, the easyjson generated functions completely ignore it.

For example this test succeeds without easyjson

type S struct {
	N int `json:"n,omitzero"`
}

func TestEasyjsonOmitZero(t *testing.T) {
	s := S{N: 0}
	b, err := json.Marshal(s)
	require.NoError(t, err)
	assert.Equal(t, "{}", string(b))
}

But if we generated JSON marshallers for S, it fails

Error:      	Not equal:
							expected: "{}"
							actual  : "{\"n\":0}"

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions