Go programming Basics

Source: Internet
Author: User

1. Go commands:

Godoc-http: 8080 // obtain the official website documentation locally

Go get // obtain the remote resource package

Go run // run the program directly

Go build // test compilation and check for any compilation errors

Go install // compile the package file and compile the entire program

 

2. Go environment variables and working directory

* Bin: stores the executable files generated after compilation.

* PKG: stores the compiled package files.

* SRC: stores the project source code.

 

3. Go environment variables:

Set goarch = amd64 // CPU architecture
Set Gobin = // bin folder in the working directory
Set gocache = c: \ Users \ xcxz \ appdata \ Local \ go-build
Set goexecmd.exe // generate the suffix of the executable file
Set goflags =
Set gohostarch = amd64 // cross-compiled Architecture
Set gohostos = Windows // cross-compiled System
Set GOOS = Windows
Set gopath = c: \ Users \ xcxz \ go // working directory
Set goproxy =
Set gw.e =
Set goroot = D: \ go // installation directory
Set gotmpdir =

4. The first go program: Hello World

(1) Create the file hello. Go in the Directory D: \ go \ SRC.

Package mainimport"FMT"Func main () {FMT. println ("Hello world, world!")}

(2) Run: D: \ go \ SRC> go run Hello. Go in cmd.

 

Go programming Basics

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.