When attempting to run a sample code for "helloworld," you encountered the following error:
compile: version "go1.9" does not match go tool version "go1.9.1"
This error indicates a discrepancy between the version specified in your code ("go1.9") and the version of the Go tool installed on your system ("go1.9.1").
If you installed Go using Homebrew on macOS, you may need to set the $GOROOT environment variable in your shell configuration file (e.g., .bashrc or .zshrc). To do this, add the following line:
export GOROOT=/usr/local/opt/go/libexec
Even if you have not previously set $GOROOT, it may still be necessary after updating from Go 1.9 to 1.9.1. This could be a potential issue with the update process.
Alternatively, you can specify the correct Go version in your code by modifying the go line in your script to:
#!/usr/bin/env go1.9.1
This will ensure that the script uses the correct version of the Go tool.
The above is the detailed content of Why does my Go code throw a 'go1.9 does not match go1.9.1' error?. For more information, please follow other related articles on the PHP Chinese website!