Skip to content

Commit

Permalink
doc/install.html: streamline the “Test your installation” step and ma…
Browse files Browse the repository at this point in the history
…ke it module-agnostic

In CL 199417, we updated “How to Write Go Code” to give a basic
introduction to modules and to include module-mode commands.
However, most new users will end up reading “Getting Started”
(doc/install.html) before “How to Write Go Code”, and we forgot to
update the handful of commands there for module mode.

Before this change, the “Test your installation” section also covered
quite a few operations beoyond merely testing the installation: it
included setting up a GOPATH, building a binary, and installing and
cleaning binaries. Those are valuable operations to learn, but they
arguably belong in “How to Write Go Code”, not “Test your
installation” — and having all that extra detail in the install
instructions may well discourage folks from further essential reading.

Rather than updating all of those operations here, I've removed them.
A companion CL will update “How to Write Go Code” to ensure that it
mentions GOPATH (as the location of the module cache and the default
install location for binaries) and 'go clean -i'.

Updates #37042

Change-Id: I157f21ccbe3896575fa1115dc821abf6c71ed15e
Reviewed-on: https://go-review.googlesource.com/c/go/+/217840
Run-TryBot: Bryan C. Mills <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Tyler Bui-Palsulich <[email protected]>
  • Loading branch information
Bryan C. Mills committed Feb 5, 2020
1 parent ffd4e32 commit 702226f
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions doc/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,11 @@ <h4 id="windows_env">Setting environment variables under Windows</h4>
<h2 id="testing">Test your installation</h2>

<p>
Check that Go is installed correctly by setting up a workspace
and building a simple program, as follows.
Check that Go is installed correctly by building a simple program, as follows.
</p>

<p>
Create your <a href="code.html#Workspaces">workspace</a> directory,
<code class="testUnix">$HOME/go</code><code class="testWindows">%USERPROFILE%\go</code>.
(If you'd like to use a different directory,
you will need to <a href="https://golang.org/wiki/SettingGOPATH">set the <code>GOPATH</code> environment variable</a>.)
</p>

<p>
Next, make the directory <code class="testUnix">src/hello</code><code class="testWindows">src\hello</code> inside your workspace,
and in that directory create a file named <code>hello.go</code> that looks like:
Create a file named <code>hello.go</code> that looks like:
</p>

<pre>
Expand All @@ -223,19 +214,17 @@ <h2 id="testing">Test your installation</h2>
</p>

<pre class="testUnix">
$ <b>cd $HOME/go/src/hello</b>
$ <b>go build</b>
$ <b>go build hello.go</b>
</pre>

<pre class="testWindows">
C:\&gt; <b>cd %USERPROFILE%\go\src\hello</b>
C:\Users\Gopher\go\src\hello&gt; <b>go build</b>
C:\Users\Gopher\go\src\hello&gt; <b>go build hello.go</b>
</pre>

<p>
The command above will build an executable named
<code class="testUnix">hello</code><code class="testWindows">hello.exe</code>
in the directory alongside your source code.
in the current directory alongside your source code.
Execute it to see the greeting:
</p>

Expand All @@ -253,12 +242,6 @@ <h2 id="testing">Test your installation</h2>
If you see the "hello, world" message then your Go installation is working.
</p>

<p>
You can run <code>go</code> <code>install</code> to install the binary into
your workspace's <code>bin</code> directory
or <code>go</code> <code>clean</code> <code>-i</code> to remove it.
</p>

<p>
Before rushing off to write Go code please read the
<a href="/doc/code.html">How to Write Go Code</a> document,
Expand Down

0 comments on commit 702226f

Please sign in to comment.