Around Go: coding agents · 3 MIN READ

Verify generated Go against the real module and runtime

Catch invented APIs, unsafe concurrency and changed wire contracts in generated Go.

Generated source can look idiomatic while targeting the wrong driver major version or changing the public result. Compile against the selected module graph, inspect authoritative APIs and test the observable path. A plausible import name or confident explanation is not version evidence.

Verify generated Go against the real module and runtime · A MAP OF THE IDEA

  1. Resolve the module
  2. Inspect the real API
  3. Trace ownership
  4. Test the failure boundary

Useful when

  • Catch invented APIs, unsafe concurrency and changed wire contracts in generated Go.
  • Resolve the actual version, compile the claimed API, review ownership and test changed public behavior. Keep native, WASI and remote-service evidence distinct.

Watch out

  • Compiling proves API compatibility for that build; database timing, failover and atomicity require additional evidence.

Implementation & operation cost: Choose the policy from the actual contract, then verify its failure path in the target environment.

01

Check which module the code actually uses

Start in the target module and inspect the workspace and selected dependencies. A local replace can make generated code compile against unreleased source. For MongoDB v2, use its /v2 path and documented lifecycle; do not add an old major version merely to make an invented call compile.

bash
go env GOMOD GOWORK
go list -m all
go doc go.mongodb.org/mongo-driver/v2/mongo.Connect
go test ./internal/store/...
Read the code

These are native-development commands in a repository that already depends on the v2 driver. go doc establishes the selected API rather than downloading a guessed dependency. The package test path must exist in that checkout.

02

Review ownership before adding goroutines

For every generated goroutine, identify who starts it, cancels it and waits for it. Check blocking sends and capacity acquisition. Acquiring a semaphore inside a newly launched goroutine can bound active work while still allowing an unbounded number of waiting goroutines.

03

Compare contracts, not just signatures

A nil slice becoming empty changes JSON under some serializers. Replacing %w with %v changes error matching. Returning success after a canceled partial export changes the protocol. Add fixtures for those decisions and check old callers before accepting a cosmetic cleanup.

04

Require a failure-path demonstration

Ask for a blocked-receiver cancellation test, duplicate request or commit-then-disconnect fixture when relevant. Run race detection on exercised concurrent paths and use integration tests for database atomicity. No amount of mocking can establish a live driver or server guarantee it never exercised.

TAKE THIS WITH YOU

Resolve the actual version, compile the claimed API, review ownership and test changed public behavior. Keep native, WASI and remote-service evidence distinct.

Check your understanding

A MongoDB example uses an old driver signature but the module uses v2. Which is the useful first check?

Go to the source

Progress stays in this browser. No account needed.