Go language Installation

Source: Internet
Author: User
Tags sublime text gocode
This is a creation in Article, where the information may have evolved or changed.

Go language Download Address: Http://tip.golang.so/dl/;googlecode not go on, Golang.org also go, anyway as long as Google's website in China can not see, only download this, but I compared a bit, and golang.org in the same.

I use the system is ubuntu14.04, can be used Apt-get:

sudo apt-get install golang

But I installed the version as if 1.2, decisively abandon the compilation installation 1.3

Download the installation package of your own system platform, Windows has an MSI installation package, relatively simple, as long as the installation is completed in the system variable path to add C:/go/bin (the bin file directory in your go installation directory), open cmd, enter go, If the go Language usage instructions are installed correctly, if you are not prompted, check if your PATH environment variable contains the GO installation directory

Linux Installation:

I am a 64-bit system, so the download is go1.3.linux-amd64.tar.gz, unzip the file

sudo tar -zxvf go1.3.linux-amd64.tar.gz /usr/local/

My go install directory is/usr/local/go you can install to random location, after the installation of the environment variables will be set, the method

sudoVim/etc/profileExportGoroot=/usr/local/goExportGoarch=amd64ExportGoos=linuxExportGopath=/home/administrator/goExportgobin=$GOROOT/binExportPath=$GOROOT/bin:$PATH sudo Source/etc/profile

Speaking of Gopath, I began to think that is the Go Language installation directory, later read a lot about go introduction just know Gopath actually can be regarded as a working directory, $GOPATH Directory Convention has three subdirectories, respectively:

1, src---------Store source code (such as:. Go,. h,. C, etc.)

2, the bin---------compiled after the executable file (for convenience, you can add this directory to the $path variable)

3. pkg--------Files generated after compilation (e.g.. a)

Test, output Hello World

 CD   $GOPATH  mkdir src pkg bincd  src mkdir testvim hello.go  

Hello.go

 PackageHelloImport "FMT"     funcMain () {FMT. Printf ("Hello world!")  }

Compile: Enter the source directory, execute go build, in the directory will automatically generate a named hello (the same as the name of the package in the source code) executable file:

./hello

Go language development tools

development tool or recommended Liteide, a cross-platform lightweight integrated development environment specifically developed for the Go language, download address: http://sourceforge.net/projects/liteide/files/

Gocode Installation

Enable the Go language input auto-completion requires installation of Gocode

go get -u github.com/nsf/gocode

Say go get command, this command is used to get remote code package, currently only support BitBucket, GitHub, Google code (this in the celestial kingdom just forget it, I can speak dirty words!) ), Launchpad (not used, back to study); This command is carried out in two steps: 1, download the source package 2, execute go Install

Before using go get first make sure your machine is installed with the corresponding tools, general git is enough, support BitBucket, GitHub, Google Code

Go development tools, such as many people are familiar with the sublime, you can use sublime Text 2 + gosublime + Gocode + Margo combination, Vim+gocode (about VIM profile online there are many), Or Eclipse and so many Ides can, and already have a lot of IDE has go plug-in, according to their own habits come.

Ok,the end!


发布于:Http://www.golune.com/blog/content/dcafaba0051124f3d2f2b4ad70591ac6b9abb

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.