Install GO environment under Unbuntu

Source: Internet
Author: User
Tags install go mercurial gocode
This is a creation in Article, where the information may have evolved or changed. (Reference: http://my.oschina.net/Obahua/blog/110767) started on the official website under the Go Linux installation package, after the installation, the implementation of go, the system prompts not to execute the binary files, do not understand what caused the cause. later, follow the above post to install:
First step: Install the Go language-related tools sudo apt-get install bison ed gawk gcc Libc6-dev make
Step Two: Install mercurial (optional, do not want to install can jump to the third step directly) Mercurial is a version management system, commonly known as HG, can be directly in the terminal input "HG" to check whether the software has been installed, because we need to from Google code in the Clone Go language source package, and its use of the version management system for Mercurial, so We need to install the software before obtaining it, it is very convenient to install under Ubuntu, and then enter the following command in the terminal: sudo apt-get install python-setuptools sudo apt-get install Python-dev sudo apt-get install build-essential sudo apt-get install mercurial
Step three: Get the Go Language source package Way One: cd jump to the go language you want to save the source path, and then terminal input: HG clone-r release Https://go.googlecode.com/hg/go
Way two: Go to the official website to download, note: Be sure to choose the right source package for your own system. Unzip to the specified location (the root directory should be set to go)

the directory structure is as shown.
Fourth Step: Configure the Go language environment variable CD ~ VI. BASHRC Add the following code: # Golang environment variable Export Goroot=/usr/softs/go Export gorach=686 Export Goos=linux Export Path=${path}:/usr/softs/go/bin Export Gopath=/usr/local/gopath
Description: Goroot:go Source Package storage location Gorash and GOOS: Related to the system, available uname-a view, mine is: Linux javagoboy-virtualbox 3.8.0-19-generic #29-ubuntu SMP Wed Apr 18:19:42 UTC i686 i686 i686 Gnu/lin UX The above 686 represents a 64-bit system, and if 386 means 32 bits. the bin directory under the Path:${path}:+go language source package, which is ${path}:${goroot}/bin Gopath: Working directory, can be modified at any time, according to the Convention, the directory contains at least three folders, respectively, bin: Used to store compiled post-build files pkg: Used to store the generated package after compilation src: Used to store various types of source files
when the edits are complete, save to exit. then execute the source. BASHRC
Fifth step: Compiling go source code CD $GOROOT/src ./all.bash wait for ... after the compilation is complete:

Next, in the terminal input command go, you can see the following interface, indicating that the Go language environment installation is complete.

Sixth step: test if the Go Language installation environment is installed successfully
cd/gopath/src VI helloworld.go Input: Package Main import "FMT" Func Main () { FMT. Println ("hello,world!") }
Save Exit then, execute go run helloworld.go Get Results:

(Reference: http://blog.csdn.net/liuhongwei123888/article/details/8512815) Seventh Step: Configure VIM to support go syntax highlighting cp-r $GOROOT/misc/vim/* ~/.vim/ VI ~/.VIMRC Add code: filetype plugin indent on Syntax on
Install Gocode:go get-u github.com/nsf/gocode, will be installed by default to the Gobin directory (mine is in the bin of Gopath), the source code in SRC. However, you need to install Git in advance, if it is not installed, execute, apt-get install git
Configuration Gocode: CD $GOPATH/src/github.com/nsf/gocode/vim execution:./update.bash Execute:/$GOPATH/bin/gocode get propose-builtins true.
Open the helloworld.go you just wrote again and you can see:

Description The configuration was successful.
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.