From 1abb863d8341b17d7de725436a85198546a9fc01 Mon Sep 17 00:00:00 2001
From: Andrew Gerrand
+Note that this differs from other programming environments in which every
+project has a separate workspace and workspaces are closely tied to version
+control repositories.
+
-The
-Go code must be kept inside a workspace.
A workspace is a directory hierarchy with three directories at its root:
-This workspace contains one repository (
-A typical workspace would contain many source repositories containing many
+A typical workspace contains many source repositories containing many
packages and commands. Most Go programmers keep all their Go source code
and dependencies in a single workspace.
Code organization
+Overview
+
+
+
+
+Workspaces
go
tool is designed to work with open source code maintained
-in public repositories. Although you don't need to publish your code, the model
-for how the environment is set up works the same whether you do or not.
-
-
@@ -77,16 +87,25 @@ src/
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) ...
src
contains Go source files organized into packages (one package per directory),
+src
contains Go source files,
pkg
contains package objects, and
bin
contains executable commands.
example
)
-comprising two commands (hello
and outyet
)
-and one library (stringutil
).
+The tree above shows a workspace containing two repositories
+(example
and image
).
+The example
repository contains two commands (hello
+and outyet
) and one library (stringutil
).
+The image
repository contains the bmp
package
+and several others.
go help gopath
-The packages from the standard library are given short paths such as +An import path is a string that uniquely identifies a package. +A package's import path corresponds to its location inside a workspace +or in a remote repository (explained below). +
+ +
+The packages from the standard library are given short import paths such as
"fmt"
and "net/http"
.
For your own packages, you must choose a base path that is unlikely to
collide with future additions to the standard library or other external