首頁  >  文章  >  後端開發  >  為什麼我的 Go 程式碼會拋出「go1.9 與 go1.9.1 不符」錯誤?

為什麼我的 Go 程式碼會拋出「go1.9 與 go1.9.1 不符」錯誤?

Barbara Streisand
Barbara Streisand原創
2024-11-13 11:35:02797瀏覽

Why does my Go code throw a

Mismatched Go Versions in "go1.9 does not match go1.9.1" Error

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").

Troubleshooting

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中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn