Fork of github.com/vmihailenco/tagparser, maintained by Quad4 under the module path github.com/Quad4-Software/tagparser/v2. The upstream helper is small and stable. This fork updates the Go toolchain, module path, layout, CI, and tests.
The parser reads comma-separated tag names and key:value options, including quoted segments and parentheses inside values.
go get github.com/Quad4-Software/tagparser/v2@latestFor local development against a checkout, point a replace directive at it:
replace github.com/Quad4-Software/tagparser/v2 => ../tagparserimport "github.com/Quad4-Software/tagparser/v2/pkg/tagparser"| Path | Contents |
|---|---|
pkg/tagparser |
Public API: Parse, Tag, HasOption |
internal/parser |
Incremental parser over bytes |
internal |
StringToBytes and BytesToString, unsafe on non-App Engine builds |
scripts/ci |
Local CI parity scripts: test-all.sh, scan-all.sh, setup-go.sh |
- Unit tests are table-driven cases in
tagparser_test.go,invariant_test.go, andtagparser_more_test.go. The low-level scanner has its own tests ininternal/parser/parser_test.go. - Property tests using pbt live in
pbt_test.goand cover no-panic guarantees, determinism, andHasOptionagainst a plain map. - Fuzz targets are
FuzzParseandFuzzDeterminismon the parser, plusFuzzUntrustedTagfor hostile inputs (NULs, long runs, bidi and unicode). Theinternalpackage hasFuzzBytesToString,FuzzStringToBytes, andFuzzConvertRoundtripasserting the unsafe conversions match plain string and byte copy semantics. internal/unsafe_invariants_test.gocheckslenandcaponStringToBytesfor non-App Engine builds. Run the safe build withgo test -tags=appengine ./internal/....stress_test.gocovers concurrent parses, long inputs, many comma-separated segments, and deep parentheses. These are skipped under-short.- Benchmarks run with
go test ./... -bench=. -benchmem -run=^$and includeBenchmarkParsesubcases, parallel and throughput benches, and theinternal/parserBenchmarkParser_ReadSep.
Example fuzz runs:
go test ./pkg/tagparser -fuzz=FuzzParse -fuzztime=30s
go test ./internal -fuzz=FuzzConvertRoundtrip -fuzztime=30sBSD 2-clause. See LICENSE. Original copyright remains with the vmihailenco authors. Fork maintenance is attributed here.