# Go regexp WebAssembly engine

This directory is the fixed bridge around Go 1.26.5's standard-library
`regexp` package. It is compiled with the official `go1.26.5` toolchain for
`GOOS=js GOARCH=wasm`; `public/engines/go/wasm_exec.mjs` must come from that
same toolchain.

The bridge accepts JSON data only. The adapter measures the exact encoded
request size, and the native cap includes JSON's worst-case sixfold escaping
for every accepted string field. It implements native RE2-family Go syntax,
native UTF-8 byte offsets, `SubexpNames`, `Find(All)StringSubmatchIndex`, and
`Regexp.ExpandString` replacement templates. Application flags `i`, `m`, `s`
and `U` become Go inline flags; `g` selects native global iteration.

Replacement uses a bounded streaming implementation of `Regexp.ExpandString`
grammar. Load-time differential fixtures compare it with the native API, and
capture references stop expanding as soon as the UTF-8 output cap is reached.
The bounded bytes cross the JSON bridge as base64, so control-heavy output has
a fixed 4:3 transport expansion instead of JSON's content-dependent escaping.

Go deliberately excludes look-around and backreferences. Its global iterator
also ignores an empty match that abuts the preceding match. Those behaviours
are tested rather than emulated.

The bridge independently caps pattern, subject, match, capture-row and output
sizes. Replacement output is clipped only at a complete UTF-8 boundary.
