Ubuntu 14.10 Compilation Installation Golang

Source: Internet
Author: User

Take the Ubuntu wiki installation tutorial as an example:

    • Install the GCC tool, because golang some of the features are written in C, so building a Golang compilation is a must
$ sudo apt-get install Bison gawk gcc Libc6-dev make
    • Install the mercurial tool to use the HG command to extract the source code of the Golang
$ sudo apt-get install mercurial
    • Pick and extract, if your network speed is slow, this step will take a little more time
$ HG Clone-r Release Https://go.googlecode.com/hg/go

After decompression, enter the directory, compile Golang

$ cd go/src$./all.bash

It was supposed to be all right, but I got stuck there when I Checking API compatibility. Studied what the next Run.bash actually did, the original

Attempting to use the previously installed Hg tool, also known as mercurial, did a version check ... All right, just delete him ...

$ sudo apt-get remove mercuial

It's all in the local operation, and there's no problem.

If a message appears, 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.

$GOBIN Golang Bin directory, here is ~/go/bin here is a configuration example: please pay special attention to the configuration of $goos and $GOARCH

$ vim ~/.BASHRC

Then join

Export Goroot=~/goexport goarch=386/amd64export goos=linuxexport gobin= $GOROOT/bin/export gotools= $GOROOT/pkg/tool/ Linux_amd64/export path= $PATH: $GOBIN: $GOTOOLS

SOURCE ~/.BASHRC
    • Create a new hello.go, and write the following:
Package Mainimport "FMT" Func Main () {FMT. Printf ("Hello, world\n")}
    • Using the Golang official website compiler (' Note: ' 6g is the go compiler for AMD64, it generates a. 6 file. Instead, 3,861 uses the 8g command, which typically generates. 8 formatted files. Of course there is a 5g command is used for ARM CPU, the same AMD64 with 6l,386 with the 8l,arm with 5L Linker! )
$6g hello.go$ 6l hello.6$./6.outhello, World


Ubuntu 14.10 Compilation installation Golang

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.