Golang Basic Primer

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

Go language is easy to get started

The first step is to install the go locale on your computer

First download the corresponding operating system installation package or source files

Both Windows and Mac OSX have an installation package, and you can choose to simply double-click the installation.

Ubuntu system can be installed using Apt-get


sudo apt-get install Golang


Of course, you can also choose to use the source package installation

Get Source:


$ HG Clone-u Release Https://code.google.com/p/go

Go to the source directory, run the installation script



$ cd go/src$./all.bash


Step two, configure the environment

Input command

Go env


Look at the GO environment on your computer, which is shown roughly as follows


Goarch= "AMD64" gobin= "gochar=" 6 "goexe=" "gohostarch=" AMD64 "gohostos=" Darwin "goos=" Darwin "Gopath="/users/zeta/ Workspace/go "gorace=" "goroot="/usr/local/go "gotooldir="/usr/local/go/pkg/tool/darwin_amd64 "CC=" clang " gogccflags= "-fpic-m64-pthread-fno-caret-diagnostics-qunused-arguments-fmessage-length=0-fno-common" CXX= "clang+ + "cgo_enabled=" 1 "

Where the Goroot,gopath setting is empty, it needs to be set manually.


Tools Catalogue in Goroot:go environment

Gopath:go install and find the default directory for packages

Step three, choose a comfortable IDE

Go currently has a number of IDE or editor options available

1.Sublime Text + gosublime Plugin

Sublime text, is a very elegant, sexy code text editor, after installing the Gosublime plugin, it becomes a very useful go language editor.

2.LiteIDE

Go language IDE, the Go language, integrates a lot of tools, simple interface.

3.Gedit

...

Fourth step, start the first project "Hello, World!" ”

Writing a sample program using the Go language is simple.

First, create a hello.go file

Then enter the following:


Package Mainimport "FMT" Func Main () {FMT. Println ("Hello, World")}

Then, on the command line, enter

Go run./hello.go

What did you see? Yes, the end of the output of Hello, the world, the Go language is so simple. A sentence to see how this sample code works.


Package main//Declaration packet name Main, a go project must have a main package import "FMT"//import FMT packet func main () {//define a main function FMT. Println ("Hello, World")//Println method using FMT, output string to terminal}


Fifth step, learn more about Go language programming and start your go language development career



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.