Hi,
I cannot tell for sure what’s wrong, but I would do these steps:
-
Call
go env GOPATH
and verify if the output is the GOPATH that you would expect.
-
Place any
.gofile under$GOPATH/src. You can use a subdirectory here; as an example, let’s call it “helloworld”. If your.gofile is calledmain.go, your Go workspace should now look like this (where GOPATH is the output fromgo env GOPATH:GOPATH +-- src | +-- helloworld | +-- main.go +-- pkg +-- bin
Now cd into GOPATH/src/helloworld and edit main.go.
A basic hello world code is:
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
Save the file and run
go run main.go
and you should get a “Hello, world!” back. (No binary file is created in this case.)
Then run
go build main.go
and you should get a binary next to your source file. And if you run
go install main.go
you should find the binary in GOPATH/bin.