← All recipes
Moderne licensed

Migrate from github.com/golang/mock to go.uber.org/mock

Recipe IDorg.openrewrite.golang.migration.MigrateToUberMockArtifactgithub.com/moderneinc/recipes-go

Migrate off github.com/golang/mock, which Google archived in June 2023, to the maintained fork go.uber.org/mock. The fork's gomock API is a superset of the original's, so this is a path swap: imports, //go:generate mockgen directives and the go.mod require all move, and call sites are untouched. Run RemoveRedundantGomockFinish afterwards to drop the defer ctrl.Finish() calls the fork makes unnecessary, and go mod tidy to sync go.sum.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.golang.migration.MigrateToUberMock

If the recipe isn’t available locally, install it with:

mod config recipes go install github.com/moderneinc/recipes-go