github.com/roboticscm/goman@v0.0.0-20210203095141-87c07b4a0a55/doc/install.html (about)

     1  <!--{
     2  	"Title": "Getting Started",
     3  	"Path":  "/doc/install"
     4  }-->
     5  
     6  <h2 id="download">Download the Go distribution</h2>
     7  
     8  <p>
     9  <a href="https://golang.org/dl/" id="start" class="download" target="_blank">
    10  <span class="big">Download Go</span>
    11  <span class="desc">Click here to visit the downloads page</span>
    12  </a>
    13  </p>
    14  
    15  <p>
    16  <a href="https://golang.org/dl/" target="_blank">Official binary
    17  distributions</a> are available for the FreeBSD (release 8 and above), Linux, Mac OS X (Snow Leopard
    18  and above), and Windows operating systems and the 32-bit (<code>386</code>) and
    19  64-bit (<code>amd64</code>) x86 processor architectures.
    20  </p>
    21  
    22  <p>
    23  If a binary distribution is not available for your combination of operating
    24  system and architecture, try
    25  <a href="/doc/install/source">installing from source</a> or
    26  <a href="/doc/install/gccgo">installing gccgo instead of gc</a>.
    27  </p>
    28  
    29  
    30  <h2 id="requirements">System requirements</h2>
    31  
    32  <p>
    33  The <code>gc</code> compiler supports the following operating systems and
    34  architectures. Please ensure your system meets these requirements before
    35  proceeding. If your OS or architecture is not on the list, it's possible that
    36  <code>gccgo</code> might support your setup; see
    37  <a href="/doc/install/gccgo">Setting up and using gccgo</a> for details.
    38  </p>
    39  
    40  <table class="codetable" frame="border" summary="requirements">
    41  <tr>
    42  <th align="center">Operating system</th>
    43  <th align="center">Architectures</th>
    44  <th align="center">Notes</th>
    45  </tr>
    46  <tr><td colspan="3"><hr></td></tr>
    47  <tr><td>FreeBSD 8 or later</td> <td>amd64, 386, arm</td> <td>Debian GNU/kFreeBSD not supported; FreeBSD/ARM needs FreeBSD 10 or later</td></tr>
    48  <tr><td>Linux 2.6.23 or later with glibc</td> <td>amd64, 386, arm</td> <td>CentOS/RHEL 5.x not supported; no binary distribution for ARM yet</td></tr>
    49  <tr><td>Mac OS X 10.6 or later</td> <td>amd64, 386</td> <td>use the gcc<sup>&#8224;</sup> that comes with Xcode<sup>&#8225;</sup></td></tr>
    50  <tr><td>Windows XP or later</td> <td>amd64, 386</td> <td>use MinGW gcc<sup>&#8224;</sup>. No need for cygwin or msys.</td></tr>
    51  </table>
    52  
    53  <p>
    54  <sup>&#8224;</sup><code>gcc</code> is required only if you plan to use
    55  <a href="/cmd/cgo">cgo</a>.<br/>
    56  <sup>&#8225;</sup>You only need to install the command line tools for
    57  <a href="http://developer.apple.com/Xcode/">Xcode</a>. If you have already
    58  installed Xcode 4.3+, you can install it from the Components tab of the
    59  Downloads preferences panel.
    60  </p>
    61  
    62  
    63  <h2 id="install">Install the Go tools</h2>
    64  
    65  <p>
    66  If you are upgrading from an older version of Go you must
    67  first <a href="#uninstall">remove the existing version</a>.
    68  </p>
    69  
    70  <h3 id="tarball">Linux, Mac OS X, and FreeBSD tarballs</h3>
    71  
    72  <p>
    73  <a href="https://golang.org/dl/">Download the archive</a>
    74  and extract it into <code>/usr/local</code>, creating a Go tree in
    75  <code>/usr/local/go</code>. For example:
    76  </p>
    77  
    78  <pre>
    79  tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
    80  </pre>
    81  
    82  <p>
    83  Choose the archive file appropriate for your installation.
    84  For instance, if you are installing Go version 1.2.1 for 64-bit x86 on Linux,
    85  the archive you want is called <code>go1.2.1.linux-amd64.tar.gz</code>.
    86  </p>
    87  
    88  <p>
    89  (Typically these commands must be run as root or through <code>sudo</code>.)
    90  </p>
    91  
    92  <p>
    93  Add <code>/usr/local/go/bin</code> to the <code>PATH</code> environment
    94  variable. You can do this by adding this line to your <code>/etc/profile</code>
    95  (for a system-wide installation) or <code>$HOME/.profile</code>:
    96  </p>
    97  
    98  <pre>
    99  export PATH=$PATH:/usr/local/go/bin
   100  </pre>
   101  
   102  <h4 id="tarball_non_standard">Installing to a custom location</h4>
   103  
   104  <p>
   105  The Go binary distributions assume they will be installed in
   106  <code>/usr/local/go</code> (or <code>c:\Go</code> under Windows),
   107  but it is possible to install the Go tools to a different location.
   108  In this case you must set the <code>GOROOT</code> environment variable
   109  to point to the directory in which it was installed.
   110  </p>
   111  
   112  <p>
   113  For example, if you installed Go to your home directory you should add the
   114  following commands to <code>$HOME/.profile</code>:
   115  </p>
   116  
   117  <pre>
   118  export GOROOT=$HOME/go
   119  export PATH=$PATH:$GOROOT/bin
   120  </pre>
   121  
   122  <p>
   123  <b>Note</b>: <code>GOROOT</code> must be set only when installing to a custom
   124  location.
   125  </p>
   126  
   127  <h3 id="osx">Mac OS X package installer</h3>
   128  
   129  <p>
   130  <a href="https://golang.org/dl/">Download the package file</a>,
   131  open it, and follow the prompts to install the Go tools.
   132  The package installs the Go distribution to <code>/usr/local/go</code>.
   133  </p>
   134  
   135  <p>
   136  The package should put the <code>/usr/local/go/bin</code> directory in your
   137  <code>PATH</code> environment variable. You may need to restart any open
   138  Terminal sessions for the change to take effect.
   139  </p>
   140  
   141  <h3 id="windows">Windows</h3>
   142  
   143  <p>
   144  The Go project provides two installation options for Windows users
   145  (besides <a href="/doc/install/source">installing from source</a>):
   146  a zip archive that requires you to set some environment variables and an
   147  MSI installer that configures your installation automatically.
   148  </p>
   149  
   150  <h4 id="windows_msi">MSI installer</h4>
   151  
   152  <p>
   153  Open the <a href="https://golang.org/dl/">MSI file</a>
   154  and follow the prompts to install the Go tools.
   155  By default, the installer puts the Go distribution in <code>c:\Go</code>.
   156  </p>
   157  
   158  <p>
   159  The installer should put the <code>c:\Go\bin</code> directory in your
   160  <code>PATH</code> environment variable. You may need to restart any open
   161  command prompts for the change to take effect.
   162  </p>
   163  
   164  <h4 id="windows_zip">Zip archive</h4>
   165  
   166  <p>
   167  <a href="https://golang.org/dl/">Download the zip file</a> and extract it into the directory of your choice (we suggest <code>c:\Go</code>).
   168  </p>
   169  
   170  <p>
   171  If you chose a directory other than <code>c:\Go</code>,
   172  you must set the <code>GOROOT</code> environment variable to your chosen path.
   173  </p>
   174  
   175  <p>
   176  Add the <code>bin</code> subdirectory of your Go root (for example, <code>c:\Go\bin</code>) to your <code>PATH</code> environment variable.
   177  </p>
   178  
   179  <h4 id="windows_env">Setting environment variables under Windows</h4>
   180  
   181  <p>
   182  Under Windows, you may set environment variables through the "Environment
   183  Variables" button on the "Advanced" tab of the "System" control panel. Some
   184  versions of Windows provide this control panel through the "Advanced System
   185  Settings" option inside the "System" control panel.
   186  </p>
   187  
   188  
   189  <h2 id="testing">Test your installation</h2>
   190  
   191  <p>
   192  Check that Go is installed correctly by building a simple program, as follows.
   193  </p>
   194  
   195  <p>
   196  Create a file named <code>hello.go</code> and put the following program in it:
   197  </p>
   198  
   199  <pre>
   200  package main
   201  
   202  import "fmt"
   203  
   204  func main() {
   205      fmt.Printf("hello, world\n")
   206  }
   207  </pre>
   208  
   209  <p>
   210  Then run it with the <code>go</code> tool:
   211  </p>
   212  
   213  <pre>
   214  $ go run hello.go
   215  hello, world
   216  </pre>
   217  
   218  <p>
   219  If you see the "hello, world" message then your Go installation is working.
   220  </p>
   221  
   222  
   223  <h2 id="gopath">Set up your work environment</h2>
   224  
   225  <p>
   226  You're almost done.
   227  You just need to set up your environment.
   228  </p>
   229  
   230  <p>
   231  Read the <a href="/doc/code.html">How to Write Go Code</a> document,
   232  which provides <b>essential setup instructions</b> for using the Go tools.
   233  </p>
   234  
   235  
   236  <h2 id="uninstall">Uninstalling Go</h2>
   237  
   238  <p>
   239  To remove an existing Go installation from your system delete the
   240  <code>go</code> directory. This is usually <code>/usr/local/go</code>
   241  under Linux, Mac OS X, and FreeBSD or <code>c:\Go</code>
   242  under Windows.
   243  </p>
   244  
   245  <p>
   246  You should also remove the Go <code>bin</code> directory from your
   247  <code>PATH</code> environment variable.
   248  Under Linux and FreeBSD you should edit <code>/etc/profile</code> or
   249  <code>$HOME/.profile</code>.
   250  If you installed Go with the <a href="#osx">Mac OS X package</a> then you
   251  should remove the <code>/etc/paths.d/go</code> file.
   252  Windows users should read the section about <a href="#windows_env">setting
   253  environment variables under Windows</a>.
   254  </p>
   255  
   256  
   257  <h2 id="help">Getting help</h2>
   258  
   259  <p>
   260  For real-time help, ask the helpful gophers in <code>#go-nuts</code> on the
   261  <a href="http://freenode.net/">Freenode</a> IRC server.
   262  </p>
   263  
   264  <p>
   265  The official mailing list for discussion of the Go language is
   266  <a href="//groups.google.com/group/golang-nuts">Go Nuts</a>.
   267  </p>
   268  
   269  <p>
   270  Report bugs using the
   271  <a href="//golang.org/issue">Go issue tracker</a>.
   272  </p>