Repository navigation
feat(go): the Go port - #32
Merged
Merged
Conversation
… lowercase, NFC and NFD
…, R0 primitives and the fixture harness
…R4 prefixes, R6 separator, R8 title side and the engine (run, runArtists, probe) The artist side (R5, R7, R9) is a temporary stand-in in go/zz_artist_stub.go until that port is merged.
…typed, to match the artist-side port
…redits, R9 assembly with near-linear dedup, R11 format
Ports rust/src/{classify,artists,credits,assemble,format}.rs. zz_title_stub.go holds
temporary scanner and positionedJunk definitions (a port of rust/src/scanner.rs) until the
title side lands; delete it at merge.
…ons, format, allArtists, R9.2 dedup vs the quadratic reference
… emphasis, kinds, bare positions, warnings with the suggestion search, parseTracklist and applyEdits The single-track pipeline is reached through engine.probe and engine.run; zz_probe_stub.go is a temporary probe until the pipeline port lands.
…go get from a clean module, install notes
… the other versions
…ead of allocating per candidate
…hared with the fuzz targets
…ions, hazards, release and code style
… tracklists, API table, ports
…t and ApplyEdits, seeded with the fixture inputs
…round code panels
…cripts/lib/ports.mjs
…cks and tracklists with edits through all four ports
…the WHATWG rule like input strings, with tests against from_utf8_lossy
…which R13.9.5 re-reads
…s, 10,000-line tracklists and 2,000 edits, and benchmarks
…ngs, and two spec gaps found by the differential run
…t express every JS value
The Go module github.com/4matic/trackparse/go implements the spec like the JavaScript, Python
and Rust packages: Parse, ParseArtists, Format, Normalize, AllArtists, Parser, ParseTracklist and
ApplyEdits, with output identical to JavaScript on every fixture.
Its options can now say every value the JavaScript options can:
- FormatOptions.FeatMarker is a *string: nil keeps the input's marker, a pointer to "" writes an
empty marker (JS featMarker: "").
- TracklistOptions.AudioSeconds is a *float64: nil is unknown, a pointer to 0 is an audio of
length 0 (JS audioSeconds: 0).
- ModeAuto is "auto", and "" means the function's default (auto for a parse, tracklist for a
tracklist), so TracklistOptions{Mode: ModeAuto} parses each line in auto mode.
- Ptr[T] returns a pointer to a copy of its argument, for the pointer fields.
A new test maps the JSON options of every fixture to the typed structs and requires the same
output bytes as the JSON door. Docs, the playground's Go code and AGENTS.md follow.
… the warning order is a switch AllWarningCodes was an exported var, and the tracklist warnings were ordered by its index, so a caller could reorder the output or race with it. warningRank is now a switch over the constants, and every exported All var (AllModes, AllRoles, AllVersionTypes, AllWarningCodes, ...) is a function that returns a new slice on each call.
It is a test tool, not something to install: under internal/ it is no longer importable from outside the module or listed as one of its commands. compare-ports and fuzz-ports run go run ./internal/cmd/dump.
…o user binaries have no init wire.go set internal/wire's hook in an init(), which kept the whole JSON door (loose-option resolution, the JSON edit reader, wireLine) reachable from every program that imports the module: a hello-world that calls Parse grew from 2.82 MB to 3.20 MB. internal/cmd/dump cannot reach unexported code any other way, and the typed API cannot carry every loose edit (fractional or boolean line numbers echo back in edit warnings), so the init moves to wire_hook.go behind the build tag trackparse_wire. compare-ports and fuzz-ports build the dump command with the tag; without it the command stops with a message. The fixture tests call wireCall directly and need no tag. CI vets and staticchecks both builds.
…sample, artist cases on demand Everything under go/ ships to every user of the module. The committed Unicode sample shrinks from 1.3 MB to 280 KB (every table range boundary, every eighth entry of the per-code-point lists, fewer random strings); CI now also runs the full sweep against Node on stable, which takes about 20 s, so no coverage is lost. testdata/artist_cases.json (2.3 MB) is no longer committed: dump_artist_cases.mjs writes it from js/dist into a git-ignored path, the artist-side tests skip without it, and go.yml writes it before go test and sets TRACKPARSE_REQUIRE_ARTIST_CASES=1 so a missing file fails there.
…or Track.UnmarshalJSON TestConcurrentUse calls a Parser with known artists and keywords, the zero Parser, Parse, ParseArtists, FormatWith, ParseTracklistWith and ApplyEdits from 16 goroutines, each starting at another input, and compares every result with the sequential one; go test -race runs it in CI. FuzzUnmarshalTrack decodes arbitrary bytes, seeded with the JSON of parsed fixture inputs, and requires the marshal/unmarshal round trip to be stable and Format, FormatWith and AllArtists not to panic on whatever decodes. The weekly fuzz job runs it for 3 minutes.
…id UTF-8 is replaced, and EditWarning.Line rounds beyond 2^53 Typed edits keep int line numbers but pass them through float64 like JavaScript numbers, so a line beyond 2^53 in magnitude is reported rounded (Delete(1<<53 + 1) gives line 9007199254740992). The doc comments now say both.
…der that keeps & < > as written json.MarshalIndent escapes & as \u0026, unlike JSON.stringify. The generated program now uses an Encoder with SetEscapeHTML(false) and SetIndent, checked by compiling snippets with Chase & Status in an artist name.
…nd the timings re-measured BenchmarkParse10k covers the blocks the docs quote (a &, feat. X, (Remix), [HD], -). Measured with go test -bench . -run '^$' -benchtime 2s on an i7-4770S, Go 1.24, and Node 24 on the same inputs (other jobs were running, so two runs each): 10,000 code points take 3 to 7 ms in Go and 4 to 18 ms in JS, a 10,000-line tracklist 0.33 to 0.38 s in Go and 0.8 to 0.9 s in JS. AGENTS.md and the site say "at most tens of milliseconds" for JS, Rust and Go.
…sions and its own Types cell The release follows the merge and the package READMEs ship in it, so the "first version comes with the next release, until then go get finds nothing" notes go from every README, the install switch and the site; go/README.md links go/CHANGELOG.md. The ports page gets Rust's Types cell back and a Go cell of its own, and says the Go output matches JavaScript on Node 24 (Unicode 17). go/README.md states what the toolchain would give instead: unicode.Version is 15.0.0 in Go 1.24, x/text/unicode/norm uses Unicode 15 below Go 1.27 and 17 from 1.27; and its Performance table has the new Go and JavaScript timings side by side.
… links the spec changelog and adds format position
…k, and SPEC_VERSION and the pin no longer name 0.5
…nd drops the stale 0.5 version
…ize and Layered comments, the dump command and changelog links in the README
…fuzz jobs, the Go time ceilings and the current site components
…racters in every language; site works with storage blocked The Rust snippets follow rustfmt's width rules (long use lists, builder chains over 60 columns, wide parse_with arguments, short line arrays, one space before a trailing comment). JavaScript and Python literals write invisible and bidi characters as \uXXXX, like the Rust and Go ones, and U+2060 to U+2064, U+00AD and other format characters are now escaped too. Shift with an empty box shifts by 0, as the generated code says. A head script gives Starlight an in-memory store when localStorage or sessionStorage throws, so its theme and tab scripts no longer stop. The landing page says labeled, and links in the feature list use the site's link style.
…the Go CI jobs, timings and links checked against the repo Modes, artists and versions show the printed values in JavaScript, Python and Rust, as the Go tabs already did. The tracklist guide no longer reuses list/tl for later examples, so the Checks section shows the first list's warnings in every language. Testing lists the module-zip job and the weekly fuzz run, the internal-pipeline fuzz target, the JS 10,000-line time (about 0.8 s) and the five linked versions.
…rential run, the Go time ceilings and the Go module's first release
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
github.com/4matic/trackparse/go, the fourth port: packagetrackparse, Go 1.22+, no dependencies, no unsafe or cgo.Behaviour
compare-portsreports 0 differences across JS, Python, Rust and Go.scripts/fuzz-ports.mjs) found 0 differences in 1,080,000 calls: 500,000 single tracks, and 290,000 tracklists each parsed and edited.x/textwould use Unicode 15 below Go 1.27 and 17 from 1.27.API
Parse,ParseWith,ParseArtists(With),Format(With),Normalize,AllArtists,Parser,ParseTracklist(With),ApplyEdits(With), the Edit constructors, andPtr.MarshalJSONwritesJSON.stringifybytes, andUnmarshalJSONround-trips.Examplefunctions for pkg.go.dev.Tests and CI
-racetest, and exhaustive Unicode checks against Node.go.yml: codegen drift, gofmt, vet, staticcheck,go test -raceon 1.22 and stable, a test of the module as downloaded (git archive), and a compare job against JS.Release
gois a linked release-please component, taggedgo/vX.Y.Z.publish-gochecks the versions, warms the module proxy and runsgo getfrom a clean module.spec.ymlchecks five versions.go/v0.6.0with all components at 0.6.0. The first real release PR is the final confirmation.Docs
go/README.md, the root and package READMEs, a Go tab on every site example (all compiled and checked), Go in the install switch and the playground's code panels, and AGENTS.md (repo map, commands, hazards, release).Found along the way, recorded in AGENTS.md as known gaps (spec decisions, not Go bugs):
formatwithfeatMarker: null: Python differs from the other three.insertnext to a bare CR.Merging opens a release PR for 0.6.0.