Avatar ·

How to install a specific version of a Go package using go get?

Hi everyone! I'm new to Go and trying to figure out dependency management. I have a project that uses the github.com/gorilla/mux library. The latest version (v1.8.0) has breaking changes that break my code. I need to install exactly version v1.7.4, which worked stably.\n\nI tried running go get github.com/gorilla/mux@v1.7.4, but I get an error: go: github.com/gorilla/mux@v1.7.4: invalid version: unknown revision v1.7.4. I also tried go get github.com/gorilla/mux v1.7.4 and go get github.com/gorilla/mux#v1.7.4 — neither works.\n\nI have Go 1.18, modules are enabled (GO111MODULE=on). Here's my go.mod file:\n\nmodule myapp\n\ngo 1.18\n\nrequire github.com/gorilla/mux v1.8.0\n\nI want to replace v1.8.0 with v1.7.4. How do I correctly specify the version? Do I need to