Skip to content

Allow prioritized list in tag directive#444

Merged
klauspost merged 4 commits into
tinylib:masterfrom
klauspost:multiple-tags
Jun 4, 2026
Merged

Allow prioritized list in tag directive#444
klauspost merged 4 commits into
tinylib:masterfrom
klauspost:multiple-tags

Conversation

@klauspost

Copy link
Copy Markdown
Collaborator

Tags are tried in order and we maintain the existing fallback.

Adds tags as alias.

Tags are tried in order and we maintain the existing fallback.

Adds `tags` as alias.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends msgp’s tag-directive handling to support a prioritized list of struct tags (tried in order) while preserving the existing fallback behavior to msg and then msgpack. It also adds tags as an alias directive and includes a generated-fixture test to validate the selection rules.

Changes:

  • Change field-tag configuration from a single tag name to a priority-ordered list (tagNames).
  • Update the tag directive to accept multiple tags (including comma-separated lists) and register tags as an alias.
  • Add _generated fixtures + tests to validate priority selection and fallback behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
parse/getast.go Reads field names from the first matching non-empty tag in a configured priority list, then falls back to msg and msgpack.
parse/directives.go Adds tags directive alias and parses tag/tags arguments into a priority list stored on FileSet.
_generated/custom_tags.go Adds a go:generate fixture demonstrating tags primary,fallback usage and fallback behavior.
_generated/custom_tags_test.go Tests encoding/decoding and verifies wire keys reflect the configured tag priority and fallback rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread parse/directives.go Outdated
Comment thread parse/directives.go Outdated
Comment thread parse/getast.go Outdated
@klauspost klauspost merged commit 801fd46 into tinylib:master Jun 4, 2026
4 checks passed
@klauspost klauspost deleted the multiple-tags branch June 4, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants