Golang Study notes: Package making

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Golang package and Java as JS, such as the big difference, must exist Gopath inside, Gopath is dedicated to store Golang third-party library, there are two folders,

SRC: Source code Directory

Pkg: Compiled third-party package, which is generated when go install, can not be manually changed

The two folders have the same file structure, as follows:

We want to make our own code base, then we have to create a new package under SRC, the package name of the file should be consistent.

For example, I create a new folder called Hehe under src:

Then open in the editor, create a package called hehe, and write a random method:

If there is no problem after build, perform the install operation, then we can see the generated package under the Pkg folder.

Then we can use this package in other projects:

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.