GO Language Specification

 

1, golang recommended hump naming nomenclature, must begin with a letter (Unicode letters) at the beginning or underscore can be followed by any number of letters, numbers, or underscores.

2, golang to determine can be accessed according to the first letter of the case. Whether it is the name of the method name, constant, variable name or structure, if the first letter capitalized, you can access by other packages; if the first letter lowercase, can only be used in this package

  can be simply understood as, first letter capitalized is public, the first letter lowercase is private

capital 3, the structure of the attribute name

if the attribute name in lower case at the data analysis (e.g. json parse, or the structure as a request or access parameters) can not be parsed

type the User struct {

        name String

        Age int

 }

FUNC main () {

         User: the User = { "Tom", 18 is}

         IF userJSON, ERR: = json.Marshal (User); ERR == nil {

           fmt.Println (String (userJSON)) // data Unable to resolve

        }

}

 

example above, if the structure of the field name in lower case, data can not be resolved. It is generally recommended in the field of capital structure

Guess you like

Origin www.cnblogs.com/otakus/p/12048876.html