Go Project Management

Source: Internet
Author: User

Install the Go compiler

sudo apt-get-qy install Golang

Create a Go Project catalog (Gopath)

Mkdir-p ~/go/sample/

Create source Directory

mkdir ~/GO/SAMPLE/SRC

Create a sub-package directory

mkdir ~/go/sample/src/package

Create a library folder

mkdir ~/go/sample/src/package/subpackage

Write the Go Library code in the sub-sub-package directory

VI Hello.go

Package Subpackageimpot "FMT" func Hello () {//Here to note, the first letter of the Hello is capitalized so that the user can access the FMT. Print ("Hello, world!");}

Installation Library

CD ~/GO/SAMPLE/SRC

Go Install Package/subpackage

After installation, a PKG folder will be created under SRC, which will have a subpackage.a file


Using the Subpackage Library

Create another subfolder

mkdir ~/go/sample/src/package/subpackage1

Writing a file

VI World.go

Package Mainimport ("FMT," Package/subpackge ") func main () {FMT. Print ("main package~\n") Subpackage.hello ()}


Run the Go install package/subpackage1 in the SRC directory

After the command executes, a bin folder will be generated in the SRC sibling directory with the SubPackage1 executable file



If you want to run the SubPackage1 command directly, you can do the following:

Run under the SubPackage1 directory

Go build world.go (compile)

Go run World.go (run)

You can also directly

Go Run world.go

This article is from the "Precipice Program Ape" blog, please be sure to keep this source http://lth2015.blog.51cto.com/10613847/1683934

Go Project Management

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.