{"repo":"rogpeppe/gohack","free":true,"listed":false,"github":"https://github.com/rogpeppe/gohack","clone":"git clone https://github.com/rogpeppe/gohack.git","description":"Make temporary edits to your Go module dependencies","language":"Go","stars":911,"topics":["go","golang","vgo","modules"],"license":"BSD-3-Clause","category":"dev-tools","readme_excerpt":"Gohack: mutable checkouts of Go module dependencies The new Go module system is awesome. It ensures repeatable, deterministic builds of Go code. External module code is cached locally in a read-only directory, which is great for reproducibility. But if you're used to the global mutable namespace that is $GOPATH , there's an obvious question: what if I'm hacking on my program and I want to change one of those external modules? You might want to put a sneaky log.Printf statement to find out how some internal data structure works, or perhaps try out a bug fix to see if it solves your latest problem. But since all those external modules are in read-only directories, it's hard to change them. And you really don't want to change them anyway, because that will break the integrity checking that the Go tool does when building. Luckily the modules system provides a way around this: you can add a replace statement to the go.mod file which substitutes the contents of a directory holding a module for the readonly cached copy. You can of course do this manually, but gohack aims to make this process pain-free. Install gohack with go get github.com/rogpeppe/gohack or use gobin : gobin github.com/rogpeppe/gohack For quick edits to a module (without version control information) If the module to edit is example.com/foo/bar , run: gohack get example.com/foo/bar This will make a copy of the module into $HOME/gohack/example.com/foo/bar and add replace directives to the local go.mod file: replace e","default_branch":null,"files":null,"tree":[],"storefront":"/r/rogpeppe","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/rogpeppe/gohack/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}