Home > Backend Development > Golang > Why does my Go code throw a 'go1.9 does not match go1.9.1' error?

Why does my Go code throw a 'go1.9 does not match go1.9.1' error?

Barbara Streisand
Release: 2024-11-13 11:35:02
Original
853 people have browsed it

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"
Copy after login

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
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template