mirror of
https://github.com/golang/go
synced 2024-11-23 07:10:05 -07:00
doc/code: drop mentions of GOPATH/pkg directory
It's already half gone and later will be all gone. It's not worth explaining in an introduction doc. Fixes #24506 Updates #4719 Change-Id: Ie48128b3aa090d84e0e734aa45f14a4480292913 Reviewed-on: https://go-review.googlesource.com/129679 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
2482451f76
commit
3e0f5f934e
@ -44,18 +44,16 @@ control repositories.
|
|||||||
<h3 id="Workspaces">Workspaces</h3>
|
<h3 id="Workspaces">Workspaces</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A workspace is a directory hierarchy with three directories at its root:
|
A workspace is a directory hierarchy with two directories at its root:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>src</code> contains Go source files,
|
<li><code>src</code> contains Go source files, and
|
||||||
<li><code>pkg</code> contains package objects, and
|
|
||||||
<li><code>bin</code> contains executable commands.
|
<li><code>bin</code> contains executable commands.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The <code>go</code> tool builds source packages and installs the resulting
|
The <code>go</code> tool builds and installs binaries to the <code>bin</code> directory.
|
||||||
binaries to the <code>pkg</code> and <code>bin</code> directories.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -72,10 +70,6 @@ To give you an idea of how a workspace looks in practice, here's an example:
|
|||||||
bin/
|
bin/
|
||||||
hello # command executable
|
hello # command executable
|
||||||
outyet # command executable
|
outyet # command executable
|
||||||
pkg/
|
|
||||||
linux_amd64/
|
|
||||||
github.com/golang/example/
|
|
||||||
stringutil.a # package object
|
|
||||||
src/
|
src/
|
||||||
<a href="https://github.com/golang/example/">github.com/golang/example/</a>
|
<a href="https://github.com/golang/example/">github.com/golang/example/</a>
|
||||||
.git/ # Git repository metadata
|
.git/ # Git repository metadata
|
||||||
@ -374,9 +368,8 @@ $ <b>go build</b>
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This won't produce an output file. To do that, you must use <code>go
|
This won't produce an output file.
|
||||||
install</code>, which places the package object inside the <code>pkg</code>
|
Instead it saves the compiled package in the local build cache.
|
||||||
directory of the workspace.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -400,19 +393,13 @@ func main() {
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Whenever the <code>go</code> tool installs a package or binary, it also
|
Install the <code>hello</code> program:
|
||||||
installs whatever dependencies it has.
|
|
||||||
So when you install the <code>hello</code> program
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
$ <b>go install github.com/user/hello</b>
|
$ <b>go install github.com/user/hello</b>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
|
||||||
the <code>stringutil</code> package will be installed as well, automatically.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Running the new version of the program, you should see a new, reversed message:
|
Running the new version of the program, you should see a new, reversed message:
|
||||||
</p>
|
</p>
|
||||||
@ -429,10 +416,6 @@ After the steps above, your workspace should look like this:
|
|||||||
<pre>
|
<pre>
|
||||||
bin/
|
bin/
|
||||||
hello # command executable
|
hello # command executable
|
||||||
pkg/
|
|
||||||
linux_amd64/ # this will reflect your OS and architecture
|
|
||||||
github.com/user/
|
|
||||||
stringutil.a # package object
|
|
||||||
src/
|
src/
|
||||||
github.com/user/
|
github.com/user/
|
||||||
hello/
|
hello/
|
||||||
@ -441,22 +424,6 @@ src/
|
|||||||
reverse.go # package source
|
reverse.go # package source
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
|
||||||
Note that <code>go install</code> placed the <code>stringutil.a</code> object
|
|
||||||
in a directory inside <code>pkg/linux_amd64</code> that mirrors its source
|
|
||||||
directory.
|
|
||||||
This is so that future invocations of the <code>go</code> tool can find the
|
|
||||||
package object and avoid recompiling the package unnecessarily.
|
|
||||||
The <code>linux_amd64</code> part is there to aid in cross-compilation,
|
|
||||||
and will reflect the operating system and architecture of your system.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Go command executables are statically linked; the package objects need not
|
|
||||||
be present to run Go programs.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<h3 id="PackageNames">Package names</h3>
|
<h3 id="PackageNames">Package names</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -597,12 +564,6 @@ tree should now look like this:
|
|||||||
<pre>
|
<pre>
|
||||||
bin/
|
bin/
|
||||||
hello # command executable
|
hello # command executable
|
||||||
pkg/
|
|
||||||
linux_amd64/
|
|
||||||
github.com/golang/example/
|
|
||||||
stringutil.a # package object
|
|
||||||
github.com/user/
|
|
||||||
stringutil.a # package object
|
|
||||||
src/
|
src/
|
||||||
github.com/golang/example/
|
github.com/golang/example/
|
||||||
.git/ # Git repository metadata
|
.git/ # Git repository metadata
|
||||||
|
Loading…
Reference in New Issue
Block a user