Issues with the go language about in-package functions for external calls

Source: Internet
Author: User

1. When defining externally accessed structures and methods within the Go Language pack, be careful to capitalize the first letter of the struct name and struct field

For example: Define the structure required for a database:

Type database struct {

      db *sql. Db

      eRR Error

}

The name of the struct and the field in the struct are not capitalized, and the error type (not defined or not found) is the correct usage:

Type Database struct{

      Db *sql. Db

      ERR Error

}

2. When defining a method for a struct, you need to capitalize the first letter of the method name

  In a struct's method, the first letter of the method name also needs to be capitalized, and no corresponding method can be found in Golang

Issues with the go language about in-package functions for external calls

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.