Go Lang Linux environment setup

Source: Internet
Author: User
Tags install go mercurial gocode

Previously, the Go Lang environment was set up on Windows. Recently, we need to build the environment on Linux. However, due to the company's need for proxy for Internet access, the download of Go source code with Hg is always unavailable, so another method is selected. Mercurial windows is installed on Windows systems (without proxy) at home. Windows is relatively simple to install, and other dependent software, such as docutils, is not required in advance, python. Now let's record the general process:

1. Download and install mercurial's windows((mercurial-2.1.exe). During installation, You must select the environment variable hook.

: Http://mercurial.selenic.com/downloads/

2. Modify the username line in the mercurial. ini file in the mercurial installation directory and change it to your username and email.

3. You can use Hg in the CMD command line to download the go source code.

Command: Hg clone-u release https://go.googlecode.com/hg/ go

4. Upload the downloaded source code to the Linux server.

5. Then you can install go.

$ CD go/src

$./All. Bash

If the installation succeeds, a message similar to this will appear, indicating that the installation is successful.

ALL TESTS PASSED---Installed Go for linux/amd64 in /home/you/go.Installed commands in /home/you/go/bin.*** You need to add /home/you/go/bin to your $PATH. ***The compiler is 6g.

The shell file cannot be executed due to permission issues. You need to modify the command: chmod-r u + X ./*
6. You need to modify the environment variable.

Add it to the. bashrc file, which is roughly as follows. You must modify different go directories:

export GOROOT=$HOME/software/goexport GOARCH=amd64export GOOS=linuxexport GOBIN=$HOME/software/go/binexport PATH=$PATH:$GOBIN

After modifying. bashrc, run the environment variable file source. bashrc and Test 6 GB,

Indicates that the go environment is successfully set up.

7. Test the go language.

$ cat >hello.go <<EOFpackage mainimport "fmt"func main() {fmt.Printf("hello, world\n")}EOF$ 6g hello.go$ 6l hello.6$ ./6.outhello, world$

8. Vim plug-in support, including the go language syntax highlighting, filetype, automatic indent, and godoc functions;

CP-RF $ goroot/MISC/Vim ~ /. Vim

Modify ~ /. Vimrc, add in it

Filetype plugin indent on
Syntax on

To make some changes to the Go language in the future, you can add every file in $ goroot/MISC/Vim ~ /. Vim.

9. As the go language does not have a fixed version yet, the current gocode cannot be compiled successfully using the latest go language, therefore, there is no way to provide auto-completion and other functions in Vim. We hope that Google will release a fixed version as soon as possible, and gocode will be able to keep up with Go changes ..................
 

 

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.