I've recently returned to Go, and am happy with almost all of the new
changes. The only one that I'm having trouble with is the "go command"
program that is now used to build packages. I wrote this in test.go:
package test
import("fmt")
func main() {
fmt.Println("working")
}
Next I ran:
$ go build -o test test.go
And then nothing happened. Nothing was printed to stdout, and the exit
code was 0. But my package did not get built as far as I can tell. I
was expecting it to appear in the current directory. I've read the
documentation here:
http://golang.org/cmd/go/. What am I doing wrong?
The next thing I tried was
$ go install test.go
go install: no install location for command-line-arguments
What are command-line-arguments? That's not a Go package as far as I
can tell, and test.go is definitely not using any command line
arguments.
Here's my go env:
GOROOT="/home/kevin/go"
GOBIN="/home/kevin/go/bin"
GOARCH="amd64"
GOCHAR="6"
GOOS="linux"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOTOOLDIR="/home/kevin/go/pkg/tool/linux_amd64"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CGO_ENABLED="1"
and $GOPATH, where test.go is in /home/kevin/goproj1:
/home/kevin/go/:/home/kevin/goproj1/
I'm probably making a stupid mistake. However, I'm someone who has
spent a considerable amount of time programming in Go. I imagine that
many beginners are making the same mistakes I am. Perhaps something
can be done to make it easier to figure out this process. At least
with the old makefile system for Go, we used to be able to see
feedback about what our errors were.