I just tried installing Go following the official doc: https://golang.org/doc/install#install
However, I encountered a problem when I tested the installation.
I created the hello.go
file like the example in the doc.
I can go build hello.go
successfully, but I cannot run the compiled binary file.
Moreover, I can go run hello.go
.
heyuan@pop-os:~/Other/temp$ cat hello.go
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
heyuan@pop-os:~/Other/temp$ go build hello.go
heyuan@pop-os:~/Other/temp$ ls
hello hello.go
heyuan@pop-os:~/Other/temp$ hello
Command 'hello' not found, but can be installed with:
sudo snap install hello # version 2.10, or
sudo apt install hello
sudo apt install hello-traditional
See 'snap info hello' for additional versions.
heyuan@pop-os:~/Other/temp$ go run hello.go
hello, world
Here are my environment variables
export GOROOT=/usr/local/go
export GOPATH=/home/heyuan/Software/go
export PATH=${GOROOT}/bin:${PATH}:${GOPATH}/bin