Build
Connect & operate
Design & teams
Start hereScope a build in one callBring a spec, a wireframe, or a paragraph. You leave with an architecture, a timeline, and a number.Book a scoping call
AI software
LLM & data systems
Vibe coding
Ready to ship?Put AI where the work isAgents, RAG, and private LLMs wired into the systems your team already uses — not a chatbot bolted to a homepage.Discuss an AI project
Domain firstWe learn your workflow before we model itRegulated, operational, or high-volume — the constraints belong in the schema, not in a training doc.Talk about your domain
Plan smarterEstimate before you commitCost ranges, scope templates, and the questions we ask in discovery — free, no form.Open the cost calculator
Real conversationsTalk with a technical leadNo SDR, no discovery gauntlet. The person on the call is the one who scopes the build.Book a call
Open-Source Testing · pact-foundation

pact-go

Pact Go is a contract testing framework for Go that enables fast, reliable API testing by validating agreements between service consumers and providers. It replaces brittle end-to-end integration tests with lightweight unit tests that verify both sides respect a shared contract.

Source: GitHub — github.com/pact-foundation/pact-go
946
GitHub stars
111
Forks
Go
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorypact-foundation/pact-go
Ownerpact-foundation
Primary languageGo
LicenseMIT — OSI-approved
Stars946
Forks111
Open issues47
Latest releasev2.5.1 (2026-05-26)
Last updated2026-06-30
Sourcehttps://github.com/pact-foundation/pact-go

What pact-go is

A Go binding to the Pact FFI (Rust-based), enabling consumer-driven contract testing for HTTP/REST and asynchronous messaging systems. Tests generate JSON contract files that providers verify locally, supporting integration into Pact Broker/Pactflow for CI/CD workflows.

Quickstart

Get the pact-go source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/pact-foundation/pact-go.gitcd pact-go# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Microservices API Integration Testing

Validate contracts between Go microservices without requiring full end-to-end test environments. Enables fast, independent provider/consumer test execution with contract sharing via Pact Broker.

Consumer-Driven Development

API consumers define expectations first; providers verify compliance independently. Reduces coupling, enables parallel development, and prevents breaking changes before deployment.

Async Messaging Systems

Test event-driven architectures (Kafka, AMQP, etc.) with contract validation for message producers and consumers, ensuring schema and payload compatibility.

Implementation considerations

  • Requires pre-installation of native libpact_ffi library and platform-specific build tools (gcc, Xcode CLI, MinGW); automates via `pact-go install` but needs sudo on macOS/Linux for /usr/local/lib. Set PACT_GO_LIB_DOWNLOAD_PATH for custom locations.
  • Consumer tests are straightforward (Arrange/Act/Assert pattern); provider verification requires running Provider service in background and pointing verifier at contract files. Mock server is ephemeral per test.
  • Contract files are JSON; design matching rules (WithBodyMatch, etc.) carefully to avoid brittle assertions while catching real breaking changes. Pact has configurable matchers for flexible comparisons.
  • Integration with Pact Broker/Pactflow requires separate setup for contract storage and can-i-deploy checks; local-only workflows skip this but lose CI/CD coordination benefits.
  • Documentation references external docs.pact.io; local README covers basics but migration guide and troubleshooting indicate v1→v2 breaking changes. Review MIGRATION.md carefully if upgrading.

When to avoid it — and what to weigh

  • Heavy CGO Dependencies Problematic — Project relies on C shared libraries (libpact_ffi) compiled from Rust, requiring CGO_ENABLED=1 and platform-specific setup (gcc/Xcode/MinGW). Cross-compilation and embedded environments are complex.
  • Simple Request-Response Testing Only — If testing is limited to basic HTTP calls without state or complex message choreography, lighter frameworks (httptest, testify) may suffice without the overhead.
  • Graphql or gRPC as Primary Protocol — README emphasizes HTTP/REST and async messaging. GraphQL and gRPC support not clearly documented; requires investigation of Pact spec compatibility.
  • Strict Commercial Support Requirements — MIT license permits commercial use but project is community-driven. SmartBear support mentioned in topics; verify SLA/support terms if enterprise backing is mandatory.

License & commercial use

MIT License (OSI-approved, permissive). Full commercial use, modification, and distribution allowed with attribution. No copyleft obligations.

MIT license explicitly permits commercial use, reproduction, and distribution. No license fees or restrictions. However, verify SmartBear support offerings (mentioned in topics) if enterprise SLAs are required; standard MIT provides no warranty or support guarantees.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceHigh
Security considerations

No security posture claimed or analyzed. CGO-dependent code expands attack surface (C library vulnerabilities). Pact mock server is test-only, not for production. Contract files are JSON; ensure access controls if contracts contain sensitive API schemas. No cryptography or authentication details in README; review docs.pact.io for TLS/auth support in mock server.

Alternatives to consider

REST Assured (Java) / Karate (Java/JS)

Language-specific contract testing; Karate offers REST/gRPC with minimal setup. If not locked to Go, these reduce native dependency complexity.

OpenAPI/Swagger + Tools (e.g., Prism, Dredd)

Spec-first approach with mock servers and validation. Lighter weight than contract testing if API schema is source of truth and consumer/provider testing is loose.

Standard Go httptest + testify/assert

Native Go, zero CGO/native deps. Sufficient for simple request-response testing; lacks contract file sharing and broker integration for microservices coordination.

Software development agency

Build on pact-go with DEV.co software developers

Start with `go get github.com/pact-foundation/pact-go/v2` and follow the 60-minute tutorial. Review CGO/native library requirements and MIGRATION guide if upgrading from v1.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

pact-go FAQ

Do I need Pact Broker or Pactflow?
No, both are optional. Local pact files work for single-team testing. Broker/Pactflow add contract versioning, can-i-deploy checks, and provider/consumer coordination in CI/CD; valuable for multi-team microservices.
Can I use Pact Go on Windows?
Yes, but requires MinGW (gcc). Use `choco install mingw` or `scoop install mingw`, set PATH and CGO_LDFLAGS. Automate via `pact-go install --libDir %TMP%` (PowerShell example in README).
What is the learning curve?
Consumer tests are easy (Arrange/Act/Assert); provider verification is straightforward (VerifyProvider with base URL + pact files). Full 60-minute tutorial available at pact-workshop-go repo. Matching rules and broker integration require deeper study.
Does Pact replace end-to-end tests entirely?
Pact reduces end-to-end test volume and cost by catching most breaking changes early. Smoke/system tests may still be needed for full flow validation. Pact is unit-level contract testing, not replacement for integration regression testing.

From evaluation to production software

DEV.co pairs senior engineers with teams adopting tools like pact-go. Our software development services span open-source testing architecture, implementation, and the AI development services that increasingly sit alongside them.

Ready to Contract-Test Your Go APIs?

Start with `go get github.com/pact-foundation/pact-go/v2` and follow the 60-minute tutorial. Review CGO/native library requirements and MIGRATION guide if upgrading from v1.