Golang Learning Notes (i): Introduction _golang

Source: Internet
Author: User
Tags error handling garbage collection

The main features of the Go language

Copy Code code as follows:

Automatic garbage collection
Richer built-in types
function multiple return value
Error handling
Anonymous functions and closures
Types and Interfaces
Concurrent programming
Language interactivity

High performance/High efficiency development


Installation Instructions Address Http://golang.org/doc/install

Package Download Address Https://code.google.com/p/go/downloads/list

Confirm that the installation is successful

Copy Code code as follows:

Go version//view versions

environment variable Settings

Overall directory structure

With package organization, only the package name called main can contain the main function

A program has and has only one main package

Import other non main packages through the Import keyword

Copy Code code as follows:

|-platform Name


Copy Code code as follows:

Package main//Declaration file Package

Import {
"FMT"//import package, cannot contain a package that is not used, otherwise the compilation error
Func Main () {//Entry function, no parameter no return value
Fmt. Println ("Hello World")

$go Run Hello.go

$go Build Hello.go

Go command

View with command line

Go Help

Copy Code code as follows:

Go build compilation
Go clean Removes the compiled build files from the current source package
Go FMT Format code
Go get dynamic Remote Code Pack
The go install generates the result file and compiles the results one to $gopath/pkg or $gopath/bin.
Go test Run the executable file for the test
Go Doc godoc-http=:8080 View document

Go fix repairs Previous versions of old code to new version
Go version View current versions
Go ENV view current GO's environment variables
Go list lists all currently installed package
Go run compile and run the Go Language program


Using GDB for debugging, the go language is built inside

Copy Code code as follows:

Set Variable

Editor settings


Other supplements

Copy Code code as follows:

* *-----/multi-line

Import multiple Packages

Copy Code code as follows:

Import (

Call the function in the package

Copy Code code as follows:


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.