title: "Go Modules: How to replace a dependency with a local copy"
date: 2020-03-20T20:35:25Z
draft: false
tags: [golang, modules]
---
Lets say you're working on a go package and you need to replace a dependency with a specific version for testing. You can use the awesome `go mod edit -replace old=new[@version]` command to do this.
This command adds a `replace` directive to your `go.mod` that overrides any require statement versions for the matching module:
```bash {hl_lines=[13]}
$ go mod edit -replace github.com/gobuffalo/packr=github.com/gobuffalo/packr@v2.8.0