Meaning of "_" Underline after Go import

Source: Internet
Author: User

Call its init function without calling its internal method
In the Golang, import is the role of importing other package, but today in the look at the Beego framework saw the import underline, do not know its meaning, so Baidu and solution.
Import underline (For example: import _ Hello/imp) Effect:
When importing a package, all init () functions are executed in the file under the package, however, sometimes we don't need to import the entire package, just want it to execute the init () function. You can use import to refer to the package at this time. Even if you refer to the package with the import _ package path only to invoke the Init () function, you cannot call other functions in the package by the package name.

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.