How to Fix compile: version “go1.9” does not match go tool version “go1.9.1”

The error compile: version “go1.9” does not match go tool version “go1.9.1” occurs when the Go version specified in your go.mod file or the environment variable GO111MODULE does not match the version of the Go toolchain installed on your system. In this case, your project requires to Go 1.9, but the installed version is Go 1.9.1.

Follow the below steps to fix the error.

Update your go.mod file

If you are using Go modules and have a go.mod file in your project, update the Go version specified in the file to match the installed version. For example:

module your_project_name

go 1.9.1

Install the required Go version

If you specifically need to use Go 1.9 for your project, you can install that version using gvm (Go Version Manager) or goenv. These tools allow you to manage multiple Go versions on your system. Once you’ve installed the required version, set it as active.

For gvm, you can use the following commands:

gvm install go1.9 

gvm use go1.9

For goenv, use:

goenv install 1.9

goenv global 1.9

Upgrade your Go installation

If you don’t specifically require to Go 1.9, consider upgrading your Go installation to a newer version. You can download the latest Go version from the official website: https://go.dev/dl/

After installing the new version, update your go.mod file or the environment variable GO111MODULE to match the new version.

By following these steps, you can resolve the version mismatch error. Remember to use a consistent Go version across your project and development environment.

That’s it!