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.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | pact-foundation/pact-go |
| Owner | pact-foundation |
| Primary language | Go |
| License | MIT — OSI-approved |
| Stars | 946 |
| Forks | 111 |
| Open issues | 47 |
| Latest release | v2.5.1 (2026-05-26) |
| Last updated | 2026-06-30 |
| Source | https://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.
Get the pact-go source
Clone the repository and explore it locally.
git clone https://github.com/pact-foundation/pact-go.gitcd pact-go# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
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.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Moderate |
| DEV.co fit | Good |
| Assessment confidence | High |
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.
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.coRelated 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?
Can I use Pact Go on Windows?
What is the learning curve?
Does Pact replace end-to-end tests entirely?
Custom software development services
DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If pact-go is part of your open-source testing roadmap, our team can implement, customize, migrate, and maintain it.
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.