Since installing 1.18, I can no longer compile even the simple demonstration program, see below.

I get the following errors. /opt/go/src/reflect/abi.go:9:2: import "internal/goarch" is a program, not an importable package /opt/go/src/internal/reflectlite/value.go:10:2: found packages runtime (abi_test.go) and main (mkduff.go) in /opt/go/src/runtime /opt/go/src/internal/syscall/unix/at.go:10:2: found packages syscall (asan.go) and main (mkasm.go) in /opt/go/src/syscall /opt/go/src/internal/poll/fd_poll_runtime.go:13:2: found packages time (embed.go) and main (genzabbrs.go) in /opt/go/src/time

I have completely deleted the go package (installed under /opt/go) and removed the directory "/home/me/go", reinstalled under /opt/go and then run "go build .". The errors still arise.

Trying to install go 1.17.8 and 1.17.7 gives me the following errors when I try to compile. compile: version "go1.17.7" does not match go tool version "go1.13.8"

Is this a bug? If not, how can I move forward. Cheers PS Running Linux Mint 20.3. =========== Go demonstration program ========== package main

import "fmt"

func main() { fmt.Println("Hello, World!") }

Comment From: ianlancetaylor

At a guess, you have set GOROOT in the environment, but the go program that is first in your PATH is using a different GOROOT.

What does printenv | grep GOROOT print?

What does which go print?

What does go version print?

Comment From: mattsmi

In order ... Note, in the interim, I have reverted to 1.13.8, which is the only version I could get working. When I install 1.18 in /opt/go, go version gives me the correct result.

GOROOT=/opt/go

/usr/bin/go

go version go1.13.8 linux/amd64

/usr/lib/go is symbolically linked to /usr/lib/go-1.13/bin/go . Does this mean that I have a system (Linux Mint) version of Go kicking around that is being invoked? If so, why does "go version" give me the right version, whenever I update.

Comment From: mattsmi

Removed the 1.13 version from /usr/bin and /usr/lib and everything is working fine now. Sorry for the bother, and thank you for helping me troubleshoot the issue.

Comment From: willianfonseca

maybe You can use a makefile too and specify or change the gopath in your makefile, It will allow you have multiple projects using different versions of golang more easy

Comment From: AllenMing3

I found that the GOROOT path and the whichgo path are very different, one is in a directory I created, and the other is under the usr directory. What should I do?

Comment From: ZhouZuYang

Perhaps the reason for this issue is that two different versions of Go were installed. Uninstalling one version and configuring the environment may solve this problem.