The following column will introduce you to the basic elements of the go program from the golang tutorial column. I hope it will be helpful to friends in need!
1. The first non-commented line in the source file must indicate which package this file belongs to
2. The package name must be lowercase, and the file name must be lowercase and underlined.
3. When you import multiple packages, it is best to arrange the package names in alphabetical order. This will make it clearer and easier to read.
//简写 import ( "fmt" "os" ) // 该方法同样适用于 const、var 和 type 的声明或定义
4,_
Underscore_
itself is a special identifier, called a whitespace identifier. It can be used in variable declarations or assignments like other identifiers (any type can be assigned to it), but any values assigned to this identifier will be discarded, so these values cannot be used in subsequent code, nor This identifier cannot be used as a variable to perform assignments or operations on other variables.
5. A source file can contain any number of lines of code. Go itself has no limit on the size of the source file.
The above is the detailed content of Do you know the basic elements of go program?. For more information, please follow other related articles on the PHP Chinese website!