Golang basic commands and use

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

1 Go Command General format:

Go command [ARG]

Where the command is the operation commands, ARG is the parameter of the command

2 Common commands

Go commands are: Get, run, build, FMT, install, test, etc.

(1) Go get
The go get command is primarily used to dynamically get remote code packages

(2) Go run

The Go Run command is used to compile and run the program directly, it generates a temporary file (but not a standard executable file), directly on the command line print output program execution results, user-friendly debugging

(3) Go build

The Go Build command is used to test the compilation package to see if there is a compilation error, and if the main package is compiled, the executable file is generated

(4) Go FMT

Go FMT format source code, some IDE save the source code when the automatic execution of the command, such as SUBL, you can also manually execute it

(5) Go install

The Go Install command has two steps: The first step is to compile the imported package file, all the imported package files are compiled before the main program is compiled, and the second step is to put the compiled executable file into the bin directory (GOPATH/BIN),compilationtranslationafterof thePackagetextpiecesput to pkg mesh record under ( GOPATH/PKG)

(6) Go test

The Go Test command is used to run the test file, which automatically reads the file named: *_test.go in the source directory, generates and runs the test executable, and the test successfully displays information such as "PASS", "OK" and so on.

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.