Use testcontainers-go to spin up a real Postgres container per test suite, run migrations, and wrap each test in a transaction that is rolled back at the end for isolation.
Build tag //go:build integration keeps integration tests separate from unit tests
Transaction rollback per test ensures test isolation without truncating tables
TestMain sets up the container once per test suite — not per test case
Pass tx (implementing DBTX interface) to the repository — works transparently
Run in CI with: go test -tags=integration ./...