Commit activity
Last 12 weeks · 0 commits
Community health
2 of 6 standards met
Recent PRs & issues
Fixes #21. Summary When parsing struct tag values, Parse() previously used strings.Split(value, ","). This unconditionally split tag values on any comma, breaking options that contained escaped commas (such as regular expressions or descriptive text like description=A reason\, hopefully a valid one). Changes Replaced unconditional strings.Split in Parse() with a custom split function that respects backslash-escaped commas. An odd number of preceding backslashes denotes an escaped comma, whereas an even number treats the comma as an option delimiter. Added comprehensive unit tests in TestParse and TestTags_EscapedCommas covering escaped commas in options, regex patterns, tag names, multiple escaped commas, and escaped backslashes preceding commas.
Fixes #24. Export sentinel errors returned by Parse, Get, and Set (ErrTagNotExist, ErrKeyNotExist, ErrKeyNotSet, ErrTagSyntax, ErrTagKeySyntax, ErrTagValueSyntax, and ErrTagKeyMismatch). This allows callers to inspect errors using errors.Is(err, structtag.ErrTagNotExist) and errors.Is(err, structtag.ErrKeyNotExist) rather than string comparisons against error messages. Internal references and unexported alias identifiers (errTagNotExist, errKeyNotExist, errKeyNotSet, etc.) remain defined for backward compatibility. Unit tests verify error matching via errors.Is.
Closes #24. Per @fatih's note on the issue, the sentinel errors were unexported, so callers were stuck doing string-compare on the message to handle a 'tag not found' specifically. Promote them to \ and keep the lowercase names as aliases so the internal call sites compile unchanged. Lets users write: \\\
Recent fixes
chore: Upgrade gomod to Go 1.21. perf: Preallocate slice in . test: Add more tests and improve test coverage. test: Move syntax error testing to . refactor: Use github.com/stretchr/testify to simplify tests. refactor: Use black-box testing (test package with "_test" suffix). refactor: Use generic slice search function to reduce code duplication. A little more than promised, but I hope you're fine with these changes living in 1 PR (saved me time). Please let me know if you want these changes to be split across multiple PRs. resolves #24
Repository: fatih/structtag. Description: Parse and modify Go struct field tags Stars: 648, Forks: 48. Primary language: Go. Languages: Go (100%). Topics: go, structs, tags. Latest release: v1.2.0 (6y ago). Open PRs: 6, open issues: 3. Last activity: 3y ago. Community health: 42%. Top contributors: fatih, vanodevium.