下面是Go的25个关键字:app
break | default | func | interface | select |
---|---|---|---|---|
case | defer | go | map | struct |
chan | else | goto | package | switch |
const | fallthrough | if | range | type |
continue | for | import | return | var |
除了上面25个关键字,Go还有36个预约义符:ui
append | bool | byte | cap | close | complex | complex64 | complex128 | uint16 |
---|---|---|---|---|---|---|---|---|
copy | false | float32 | float64 | imag | int | int8 | int16 | uint32 |
int32 | int64 | iota | len | make | new | nil | panic | uint64 |
println | real | recover | string | true | uint | uint8 | uintptr |
标识符是程序设计语言中用来规定具备特色含义的词,好比类的名称,属性,变量名称等。Go的标识符必须知足下面几个条件:设计
在Go中一行表明语句的结束,不要像类C的其它语言同样用分号结尾code
Go的注释和C语言相似,//开头表明单行注释。多行注释能够用/*开头,并用 */结尾string
// 单行注释 /* 做者:海盗 日期: xxx */
Go 语言中空格是为了加强代码的可读性,可是变量的声明必需要用空格隔开如:it
var name string; i=i+j i = i + j
fmt.Println()是换行输出,若是要不换行用fmt.Print()io
fmt.Print("test") fmt.Println("Hello World!")