Error GOLang: no install location for directory

I just made a mistake related GOPATH on my local environment while learning Golang, here is the error I got:

yusuf@yusuf-he:~/go-learn2/$ go install
go install: no install location for directory /home/yusuf/go-learn2/ outside GOPATH
For more details see: go help gopath

and I realized that the mistake was:


here is the official documentation regarding golang Workspace Directory Structure

A workspace is a directory hierarchy with three directories at its root:

  • src contains Go source files,
  • pkg contains package objects, and
  • bin contains executable commands.

The go tool builds source packages and installs the resulting binaries to the pkg and bin directories.

The src subdirectory typically contains multiple version control repositories (such as for Git or Mercurial) that track the development of one or more source packages.

To give you an idea of how a workspace looks in practice, here’s an example:


here is the official documentation regarding $GOPATH

The GOPATH environment variable

The GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you’ll need to set when developing Go code.

To get started, create a workspace directory and set GOPATH accordingly. Your workspace can be located wherever you like, but we’ll use $HOME/work in this document. Note that this must not be the same path as your Go installation. (Another common setup is to set GOPATH=$HOME.)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s