Basic go programming: few built-in keywords (25)
Break default func interface select
Case defer go map struct
Chan else goto package Switch
Const fallthrough if range type
Continute for Import Return VaR
Go annotation method (same as JS)
Single line comment ://
Multi-line comment :/**/
The general structure of the Go program is common_structure.go.
- PassPackageOrganize code structures (similar to Python modules)
- OnlyPackageName:MainThe package can containMainFunction
- One executable program has only oneMainPackage
- PassImportTo import packages
- ConstUsed to define constants (similar to C)
- External Use of function bodyVaRTo declare and assign values to global variables.
- Complex typesStruct,InterfaceTo useTypeKeyword to declare
- FuncTo declare a function
Simple demo
/*title: common_structure.goauthor: orangleliudate: 2014-08-05des: the simple demo of erlang*/// a package only have a mainpackage main// use “import” import other packagesimport “fmt”const Lzz = “Orangleliu”var name = “erlong”type age inttype golang struct{}func main(){ fmt.Println(“I love Erlog!”)}
1. How to import multiple packages
import ( “fmt” “os” “time”)
2. use aliases
import ( std “fmt”)
Naming Conventions
Case SensitiveConstant, variable, type, interface, structure or functionPublic or private
For example:
1. The first letter of the function name is lowercase: Private
2. function names are capitalized: Public
Learning material address
This article is from the "orangleliu notebook" blog, please be sure to keep this http://blog.csdn.net/orangleliu/article/details/38393085