Go Basic Engineering Construction < one >

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

1 About Go source code

Each go source code starts from the package {XXXX packet declaration }, which indicates that the go code belongs to this pack. Package is the most basic distribution unit of Go, and also the system of dependency in engineering management.

The go executable starts with the main function of the main package, and the main function has no parameters and no return.

Package Mainimport "FMT"   //We need to use the println () function in the FMT packet func main () {        fmt. Println ("Hello, World")}


2 Engineering Documents

Go using directory structure, folders to push the project structure, generally, to build a project requires three folders
If the project is placed in the catalogue/data/pro/demo   <demo>├─<src>├─<libs>|--<event>hh.go├─<demo> ├─demo.go├─demo_hh.go├─demo_test.go├─<bin> #可执行文件目录 ├─<pkg># package will be installed here

Note that the project catalog must be

/data/pro/demo set to environment variable $GOPATH

2 Go Engineering Compilation installation

the revolutionary point of the GO command-line tool is to completely eliminate the concept of the project file, fully using the directory structure and the package name to derive the engineering structure and build order.

The construction project needs to add the project's root directory to the environment variable Gopath

In the directory where the main package is located, perform go install

All dependent packages can be compiled and installed into the PKG to compile the executable program into the bin
Additional Command instructions:

Go Build {xxx.go ... }

Go run compile and run

More Command Reference




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.