Go installation and configuration process

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


Finally began to learn go, thoughts quickly, continue difficult, write down will be better

1. Installation

There are many options for installation, such as direct Apititude Golang, under Ubuntu, but in order to be customizable, or go directly to the Golang official website to download the installation package self-installation, the specific process see: golang.org site downloaded and installed A, directly extracted to/usr/ Under Local

2.go Run Configuration path:

Export Goroot=/usr/local/go
Export path= $PATH:/usr/local/go/bin

3. Working Environment Path configuration:

Export gopath=/home/@user/work/goexport gobin= $GOPATH/binexport path= $GOPATH/bin: $PATH
This will ensure that you find your own compiled package or you can compile your own executable file under the system path.

4. Catalog creation:


Mkdir-p $GOPATH/src  $GOPATH/pkg   $GOPATH/bin


5. Sample Programs

Create a new directory under SRC test, creating Test.go, as follows:
Package Mainimport "FMT" Func Main () {        fmt. Println ("Hello World, I ' m Learning Golang")}

Go to the $gopath/bin directory, go run test, you can find the test executable file in the bin directory
Attached: How to compile a custom pkg, can be described in the next article (this is the role of our Pkg directory)

6.vim Configuration

Careful friends will find that, to this step, our code is still very difficult to see, because there is no configuration file, this is our official website downloaded from the file has played a role (this is not directly recommended aptitude purpose)
CD $GOROOT/misc/vim && cp-fr * ~/.vim/&&   echo "au bufread,bufnewfile *.go set filetype=go" > ~/.V Im/ftdetect/go.vim
OK, syntax highlighting complete, done


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.