Está en la página 1de 4

Documents

References

Packages

The Project

Help

Play

Search

Send Feedback

The Go Programming Getting Started Language


Download the Go distribution System requirements Install the Go tools FreeBSD, Linux, Mac OS X and NetBSD tarballs Mac OS X package installer Windows Test your installation Set up your work environment What's next Community resources

Download the Go distribution Download Go


Click here to visit the downloads page

Click the link above to visit the Go project's downloads page and select the binary distribution that matches your operating system and processor architecture. Official binary distributions are available for the FreeBSD, Linux, Mac OS X (Snow Leopard, Lion, and Mountain Lion), NetBSD, and Windows operating systems and the 32-bit (3 8 6 ) and 64-bit (a m d 6 4 ) x86 processor architectures. If a binary distribution is not available for your combination of operating system and architecture you may want to try installing from source or installing gccgo instead of gc.

System requirements
The g ccompiler supports the following operating systems and architectures. Please ensure your system meets these requirements before proceeding. If your OS or architecture is not on the list, it's possible that g c c g omight support your setup; see Setting up and using gccgo for details. Operating system Architectures FreeBSD 7 or later Linux 2.6.23 or amd64, 386, arm amd64, 386, Notes Debian GNU/kFreeBSD not supported; FreeBSD/ARM needs FreeBSD 10 or later CentOS/RHEL 5.x not supported; no binary

later with glibc Mac OS X 10.6/10.7 Windows 2000 or later NetBSD 6 or later
g c cis You

arm amd64, 386 amd64, 386 amd64, 386

distribution for ARM yet use the gcc that comes with Xcode use mingw gcc; cygwin or msys is not needed

required only if you plan to use cgo. only need to install the command line tools for Xcode. If you have already installed Xcode 4.3+, you can install it from the Components tab of the Downloads preferences panel.

Install the Go tools


The Go binary distributions assume they will be installed in / u s r / l o c a l / g o(or c : \ G o under Windows), but it is possible to install them in a different location. If you do this, you will need to set the G O R O O Tenvironment variable to that directory when using the Go tools. For example, if you installed Go to your home directory you should add the following commands to $ H O M E / . p r o f i l e :
e x p o r tG O R O O T = $ H O M E / g o e x p o r tP A T H = $ P A T H : $ G O R O O T / b i n

Windows users should read the section about setting environment variables under Windows.

FreeBSD, Linux, Mac OS X and NetBSD tarballs


If you are upgrading from an older version of Go you must first remove the existing version from / u s r / l o c a l / g o :
r mr/ u s r / l o c a l / g o

Extract the archive into / u s r / l o c a l , creating a Go tree in / u s r / l o c a l / g o . For example:


t a rC/ u s r / l o c a lx z fg o 1 . 1 . l i n u x a m d 6 4 . t a r . g z

The name of the archive may differ, depending on the version of Go you are installing and your system's operating system and processor architecture. (Typically these commands must be run as root or through s u d o .) Add / u s r / l o c a l / g o / b i nto the P A T Henvironment variable. You can do this by adding

this line to your / e t c / p r o f i l e(for a system-wide installation) or $ H O M E / . p r o f i l e :


e x p o r tP A T H = $ P A T H : / u s r / l o c a l / g o / b i n

Mac OS X package installer


Open the package file and follow the prompts to install the Go tools. The package installs the Go distribution to / u s r / l o c a l / g o . The package should put the / u s r / l o c a l / g o / b i ndirectory in your P A T Henvironment variable. You may need to restart any open Terminal sessions for the change to take effect.

Windows
The Go project provides two installation options for Windows users (besides installing from source): a zip archive that requires you to set some environment variables and an experimental MSI installer that configures your installation automatically. Zip archive Extract the zip file to the directory of your choice (we suggest c : \ G o ). If you chose a directory other than c : \ G o , you must set the G O R O O Tenvironment variable to your chosen path. Add the b i nsubdirectory of your Go root (for example, c : \ G o \ b i n ) to your P A T H environment variable. MSI installer (experimental) Open the MSI file and follow the prompts to install the Go tools. By default, the installer puts the Go distribution in c : \ G o . The installer should put the c : \ G o \ b i ndirectory in your P A T Henvironment variable. You may need to restart any open command prompts for the change to take effect. Setting environment variables under Windows Under Windows, you may set environment variables through the "Environment Variables" button on the "Advanced" tab of the "System" control panel. Some versions of Windows provide this control panel through the "Advanced System Settings" option inside the "System" control panel.

Test your installation


Check that Go is installed correctly by building a simple program, as follows.

Create a file named h e l l o . g oand put the following program in it:


p a c k a g em a i n i m p o r t" f m t " f u n cm a i n ( ){ f m t . P r i n t f ( " h e l l o ,w o r l d \ n " ) }

Then run it with the g otool:


$g or u nh e l l o . g o h e l l o ,w o r l d

If you see the "hello, world" message then your Go installation is working.

Set up your work environment


The document How to Write Go Code explains how to set up a work environment in which to build and test Go code.

What's next
Start by taking A Tour of Go. Build a web application by following the Wiki Tutorial. Read Effective Go to learn about writing idiomatic Go code. For the full story, consult Go's extensive documentation. Subscribe to the golang-announce mailing list to be notified when a new stable version of Go is released.

Community resources
For real-time help, there may be users or developers on # g o n u t son the Freenode IRC server. The official mailing list for discussion of the Go language is Go Nuts. Bugs should be reported using the Go issue tracker.

Build version go1.1.2. Except as noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code is licensed under a BSD license.

También podría gustarte