"go tool compile" failing with package not found error

I installed go 1.22.6 from archive for linux_amd64, unzipped, added go to PATH and re-ran the ~/.bashrc.

Then I also copied the same version into /opt/go1.22 for running make.bash by setting GOROOT_BOOTSTRAP to this /opt/go1.22.

And created a small hello.go program which imports “fmt” and tried to compile it using

go tool compile -o hello hello.go

But then I got the error package not found “fmt”.

I checked for archive files in /usr/local/go/pkg/linux_amd64 but there not linux_amd64 directory in /pkg

I am not sure why it is not generating.

Any insights / solutions would really help.

Thank you.

but, why you use go tool instead of go build?

Hello there, I guess this discussion is related and can explain that it’s the way it suppose to work

2 Likes