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.
以上是為什麼我的 Go 程式碼會拋出「go1.9 與 go1.9.1 不符」錯誤?的詳細內容。更多資訊請關注PHP中文網其他相關文章!