Go language with the so-called package

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

Import is followed by the name of the directory, not the name of the package, and if there is a directory under the directory, it must be written in, such as:

" MyPackage "  "mypackage/myinnerpackage"

Here to understand the import is followed by the directory name instead of the file name is not the so-called package name, then a directory of the following files can be more than one package? No

" MyPackage "  "mypackage/myinnerpackage" "Otherpackage"  func Main () {    mypackage.myfunc ();    Mypackage.myfunc ();    Myinnerpackage.myinnerfunc ()    otherpackages.myotherfunc ()}

There are two directories under the SRC directory, namely MyPackage and Otherpackage

" FMT " func MyFunc () {    fmt. Println ("MyFunc");}
" FMT " func MyFunc2 () {    fmt. Println ("MyFunc2")}

" FMT " func Myinnerfunc () {    fmt. Println ("myinnerpackage")}

" FMT " func Myotherfunc () {    fmt. Println ("otherpackages->myotherfunc");}

There's a pervert in the go language. You have to expose the method or attribute name must be capitalized in the first letter.

In Go, the a name is exported if it begins with a capital letter.

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.