Table of Contents

About

The workspace is the root directory of all work in go

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.

Environment variable

echo $GOPATH
go help gopath

gopath

Example

  • Two repositories (example and image).
    • The example repository (src/github.com/golang/example/) contains:
      • Two commands (hello and outyet)
      • one library (stringutil).
    • The image repository (src/golang.org/x/image/) contains the:
      • bmp package
      • and several others.
bin/
    hello                          # command executable
    outyet                         # command executable
pkg/
    linux_amd64/
        github.com/golang/example/
            stringutil.a           # package object
src/
    github.com/golang/example/
        .git/                      # Git repository metadata
	hello/
	    hello.go               # command source
	outyet/
	    main.go                # command source
	    main_test.go           # test source
	stringutil/
	    reverse.go             # package source
	    reverse_test.go        # test source
    golang.org/x/image/
        .git/                      # Git repository metadata
	bmp/
	    reader.go              # package source
	    writer.go              # package source
    ... (many more repositories and packages omitted) ...

Documentation / Reference