How to Test Local Changes with Go Mod

Teiva Harsanyi
Aug 7, 2019


We are developing on two different Go projects using modules:

  • A module
  • Another module that depends on the first one

Let鈥檚 say we made some changes to and we would like to test the impacts on before committing them.

Without Go modules, it was pretty straightforward as our changes were done in GOPATH so they were automatically reflected.

With Go modules, the trick is to replace our import by the physical location of the project:

Here, /path/to/local/bar is the actual location of the bar project containing the local changes.

We can also use the following command:

go mod edit -replace


Follow me on Twitter @teivah



Teiva Harsanyi

Software Engineer @Google | 馃摉 100 Go Mistakes author | 鏀瑰杽