Go Language Customization Package

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

Go Language Customization Package

A package is a collection of functions and data. Define a package with the bundle keyword. File name does not need to be associated with package name
Consistent, but your folder must be consistent with the package name, which is important, so for simplicity, the name is the same. The Convention for package names is to use lowercase characters. A Go package can consist of multiple files, but using the same
Package this line. Let's define a package called PAC in the file pac.go.

1 Packages of code:

Package PAC

Import (
"FMT"
)

Func Printt (x string) {
Fmt. PRINTLN (x + "Love Liu Hanlin")

}
Func printtt (x string) {
Fmt. PRINTLN (x + "Love Liu Hanlin")

}

program code to invoke the package

Package Main

Import (
"FMT"
"PAC"
)

Func Main () {

pac.Printt("凯凯")

}

3 in your $goroot/src/pkg/pac/directory into your package file

% Go Build
% go Install

4 in your work Gopath directory

Go Build Demao.go
Demao.exe

Run results

Kaikai Love Liu Hanlin

License

Copyright (c) qiniu.com

Based on the MIT protocol release:

    • Www.opensource.org/licenses/MIT
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.