go install: no install location for .go files listed on command line (GOBIN not set)
Create a bin
directory under GOPATH parallel to src
.
For e.g:
GOPATH=/home/user/go
GOBIN=$GOPATH/bin
EDIT: after comment interaction.
Create your go workspace, refer to workspace doc
For e.g.:
Directory Structure: GOPATH is /home/user/go
/home/user/go/src/pic-project
└── pic.go
Go to /home/user/go/src/pic-project
go build pic.go
ls -ltr
-rw-r--r-- 1 jeeva staff 84 Jun 23 23:55 pic.go
-rwxr-xr-x 1 jeeva staff 1624096 Jun 24 00:02 pic
Binary is in the same directory.
Now, let's do go install
, you can execute install command in following ways.
Inside project directory (binary will be in $GOPATH/bin
directory)
go install
OR from anywhere in the terminal-
go install pic-project
Also if you have project with main func and sub packages. Execute go install <import-path>
, it will produce binary and sub-packages as .a
files.
go install github.com/user/foo
You will find foo.a
under $GOPATH/pkg/GOOS_GOARCH/github.com/user/foo.a
and binary in the $GOPATH/bin
directory.