CheckOps
GoMock (uber-go/mock)
GoMock is an Apache-2.0 mocking framework for Go, maintained by Uber after the original golang/mock was archived, with the mockgen code generator and a gomock controller for expectations.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
GoMock is a mocking framework for Go that integrates with the built-in testing package. The original project at golang/mock was archived, and Uber maintains the continuation at go.uber.org/mock, which is now the recommended version.
The mockgen tool generates mock implementations from Go interfaces, either from source files (-source) or from a package and interface names. In tests you create a gomock.Controller, construct the generated mock, and set expectations with EXPECT().Method(args).Return(values), using matchers such as gomock.Any(), gomock.Eq() and custom matchers, call counts (Times, AnyTimes), ordering (gomock.InOrder) and actions (DoAndReturn). Unmet or unexpected calls fail the test automatically. mockgen can be wired into go generate so mocks stay in sync with interfaces. Version 0.6.0 was released on 18 August 2025, with commits continuing in August 2026.
The source code is at uber-go/mock on GitHub under the Apache-2.0 licence, with about 3,400 stars; the most recent commit was on 25 August 2026.
Features
- Code generation:
mockgencreates type-safe mocks from interfaces. - Expectations:
EXPECT()with matchers, counts and ordering. - go generate integration: Keep mocks in sync with interfaces.
- Maintained fork: Uber’s continuation of the archived golang/mock.
Pros
- Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 25 August 2026.
- Community: About 3,400 GitHub stars.
Cons
- Generated code to maintain: Mocks must be regenerated when interfaces change.
- Can encourage over-specification: Strict expectations make tests brittle if overused.
Usage and Links (Example)
go install go.uber.org/mock/mockgen@latest
mockgen -source=store.go -destination=mocks/store_mock.go -package=mocks
func TestCheckout(t *testing.T) {
ctrl := gomock.NewController(t)
store := mocks.NewMockStore(ctrl)
store.EXPECT().Save(gomock.Any()).Return(nil).Times(1)
svc := NewCheckout(store)
if err := svc.Place(Order{Total: 100}); err != nil {
t.Fatal(err)
}
}
Resources:
Pricing
GoMock (uber-go/mock) is free and open source under the Apache-2.0 licence.
Recommended for?
- Go teams wanting generated, type-safe mocks with strict expectations.
- Codebases migrating from golang/mock.
Conclusion
GoMock, now maintained by Uber, is the standard generated-mock framework for Go.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with GoMock (uber-go/mock) side by side.
TTestifyTestify is an MIT-licensed Go toolkit with assert and require assertion packages, mock objects and test suites, the most widely used testing library in the Go ecosystem.Compare with GoMock (uber-go/mock)
GGo testing packageGo's built-in testing package and go test command provide unit tests, table-driven subtests, benchmarks, fuzzing, examples and coverage with no third-party dependencies.Compare with GoMock (uber-go/mock)
GGinkgoGinkgo is an MIT-licensed BDD-style testing framework for Go with Describe/Context/It specs, parallel execution, focused and labelled specs and rich reporting, usually paired with the Gomega matcher library.Compare with GoMock (uber-go/mock)
GGomegaGomega is an MIT-licensed matcher and assertion library for Go, designed for Ginkgo but usable with plain go test, with asynchronous Eventually/Consistently assertions.Compare with GoMock (uber-go/mock)
MMockallMockall is a powerful mock object library for Rust, generating mocks for traits and structs with the #[automock] attribute or mock! macro, with expectations, predicates and call counts.Compare with GoMock (uber-go/mock)
MMockitoMockito is the MIT-licensed, most popular mocking framework for Java, used to create mocks, stubs and spies with a clean API; Mockito 5 uses the inline mock maker by default and requires Java 11.Compare with GoMock (uber-go/mock)