One static lookup without an array driver in Laravel Go
Scope
Extract one immutable, bounded Sushi row set into release-owned code/label values and an explicit lookup. Preserve exact identities, order, missing results and resource fields. Exclude dynamic getRows, remote/user/tenant data, mutable records, general query emulation, relationships and model-backed validation rules. Keep excluded callers on their old path. Preserve the upstream MIT notice for adapted source.
At the time of writing, the Package Port catalog listed Go and Rust gaps. Check get-recipe's current port catalog; a small typed list can serve this subset without an array database. This guidance has not been exercised in your app; verify it with the checks below.
Source behaviour
src/Sushi.php constructs a SQLite table from getRows, infers columns from the first row unless schema overrides apply, may add an incrementing key, and inserts in chunks. Its inference treats numeric-looking values before ordinary strings, making schema/casts important for codes with leading zeros.
Cache eligibility defaults to a rows property and freshness is based on the reference file's modification time; unsupported cache paths can fall back to in-memory SQLite. This does not make writes durable or track arbitrary external data changes. tests/SushiTest.php covers schema, empty rows, cache selection and relationships. The same-cache-between-requests test is skipped, not evidence of worker consistency.
Implementation
- Inspect the actual source, schema/casts, generated IDs, ordering, scopes/accessors, all writes, relationships and model-based validation. Select one trusted list shipped with the release. Preserve any externally referenced generated IDs as explicit values; reordering must not change identity.
- Keep typed rows beside the owning feature and validate the complete data at startup: exact unique string codes, non-null string labels, required fields and bounded count. Preserve leading zeros, Unicode and declared order. Reject duplicate codes rather than letting a map overwrite one. Do not expose a mutable shared slice/map to request code.
- Replace just the selected code lookup. Return a presence flag so an empty label is not missing. Exact string comparison deliberately differs from SQLite coercion/collation where the old query allowed it; compare real fixtures and preserve or document that difference. Unknown codes do not fall back to a first/default record unless that is explicitly the old contract.
- Keep existing request context, authorization, tenant rules and resource projection. Only public tenant-independent values belong in process-wide immutable storage. Never use client input as a file path or remote URL. An authorized response must not be cached globally, and labels are not trusted HTML.
- No database/cache file, transaction or migration is required for this subset. Deploy rows with code and refresh every long-lived worker. If rows change outside releases, retain or separately design the existing storage/invalidation instead. Do not delete old SQLite/durable data during the initial extraction. Keep other model queries until replaced.
Complete pure lookup for already validated unique rows. It returns a string copy and presence flag; the caller owns initialization, access control and transport mapping. Keep the input slice read-only:
type Zone struct { Code, Label string }
func zoneLabel(zones []Zone, code string) (string, bool) {
for _, zone := range zones {
if zone.Code == code {
return zone.Label, true
}
}
return "", false
}
Acceptance checklist
- For
01: North,1: South,10: "", expect distinct exact labels, a present empty value for10, and absent for001, unknown codes and empty input. Numeric conversion would fail this fixture. - Reject duplicate codes, non-string fields and oversized lists before serving. Preserve Unicode/order and compare schema/collation differences against source-backed results.
- Keep referenced IDs stable and compare response/not-found semantics. Retain all excluded queries, relationships, scopes, accessors or model-validation behavior still in use.
- Unauthorized/cross-tenant values never enter shared data or another tenant's response. Concurrent readers pass race checks, and workers refreshed after a release observe its new rows.
- The selected lookup performs no database/network/file writes. Verify no dynamic data or write behavior was hidden in
getRowsbefore dependency removal.
Run gofmt, go vet ./..., go test ./..., go test -race ./... and app resource/authorization/release-refresh tests. Record versions, outputs and accepted differences with the change; a pure lookup does not prove SQL equivalence.
Sources
- MIT reference source:
src/Sushi.phpandtests/SushiTest.php. PreserveLICENSE.md. - Framework source checked:
web/request.go; preserve the app's context/response boundary and reconcile metadata with its module revision. The lookup itself needs no framework database API. - Port options: check
get-recipe's current port catalog (sourced from Package Port) at implementation time.