Directory structure of the GO Project

Source: Internet
Author: User

Transferred from: http://blog.studygolang.com/2012/12/go%E9%A1%B9%E7%9B%AE%E7%9A%84%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84/


How the project directory structure is organized, the general language is not specified. But the go language is a rule, so you can maintain consistency. 1, General, a go project under Gopath, there will be the following three directories:

1 |--bin
2 |--pkg
3 |--src

Where the bin holds the compiled executable file, the PKG holds the compiled package file, and SRC holds the project source file. Generally, the bin and pkg directories can be created without the GO command being created automatically (like go install), just create the SRC directory.
For the Pkg directory, someone once asked: I put the package go under the pkg, how can not ah. He directly put the go package source files into the pkg. This is obviously wrong. The files in the pkg are generated by go compilation, rather than manually put in. (General file suffix. a)
For the SRC directory, the source files are stored in the go, and the source files are organized in the form of packages. In general, creating a new package creates a new folder in the SRC directory. 2. Examples and explanations

For example: I create a new project, test, the starting directory structure is as follows:

1 Test--|--src

In order to compile conveniently, I added an install file in it, directory structure:

1 test/
2 |--Install
3 '--src

The contents of the install are as follows: (Linux)

1 #!/usr/bin/env Bash
2
3 if [!-f Install]; Then
4 Echo ' Install must is run within its container folder ' 1>&2
5 Exit 1
6
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.