This repository is a fork of github.com/vmihailenco/tagparser (v2 API), maintained by Quad4 at github.com/Quad4-Software/tagparser. The upstream helper is small and stable; this fork updates the Go toolchain, module path, layout, CI, and tests.
Import the library as:
import "github.com/Quad4-Software/tagparser"Install:
go get github.com/Quad4-Software/tagparser@latestThe module path is github.com/Quad4-Software/tagparser. Library sources live under pkg/tagparser/; internal/parser holds the low-level byte scanner; internal provides App Engine–safe or unsafe string/byte helpers.
- Parses comma-separated tag names and
key:valueoptions, including quoted segments and parentheses in values.
| Path | Purpose |
|---|---|
pkg/tagparser |
Public API (Parse, Tag, HasOption) |
internal/parser |
Incremental parser over bytes |
internal |
StringToBytes / BytesToString (unsafe on non-App Engine) |
scripts/ci |
Local CI parity with Gitea (test-all.sh, scan-all.sh, setup-go.sh, …) |
.gitea/workflows |
CI (ci.yml) and security scan (scan.yml) |
- Unit: table-driven cases in
tagparser_test.go,invariant_test.go,tagparser_more_test.go; low-levelinternal/parsertests ininternal/parser/parser_test.go. - Property-based: pbt in
pbt_test.go(no panic, determinism,HasOptionvs map). - Fuzz:
FuzzParse/FuzzDeterminismon the parser;FuzzUntrustedTagfor hostile-style inputs (NULs, long runs, bidi/unicode).internal:FuzzBytesToString,FuzzStringToBytes,FuzzConvertRoundtripassert unsafe (or safe) conversions matchstring/[]bytecopy semantics. Example:
go test ./pkg/tagparser -fuzz=FuzzParse -fuzztime=30s
go test ./internal -fuzz=FuzzConvertRoundtrip -fuzztime=30s - Unsafe vs App Engine:
internal/unsafe_invariants_test.go(!appengine) checkslen/caponStringToBytes. Run the safe build withgo test -tags=appengine ./internal/.... - Stress (skipped with
-short): concurrent parses, long inputs, many comma-separated segments, deep parentheses instress_test.go. - Benchmarks:
go test ./... -bench=. -benchmem -run=^$— includesBenchmarkParsesubcases, parallel and throughput benches, andinternal/parserBenchmarkParser_ReadSep.
BSD 2-clause; see LICENSE. Original copyright remains with the vmihailenco authors; fork maintenance is attributed in this README.