(一)查找定位
(二)代码编辑
(一)注释
(二)语句的结尾
(三)可见性规则
(一)关键字
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 |
(二)预定义标识符
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一般结构
// 当前程序包名
package main
// 导入其他包
import . "fmt"
// 常量定义
const PI = 3.14
// 全局变量的声明和赋值
var name = "golang"
// 一般类型声明
type newType int
// 结构的声明
type gopher struct{}
// 接口的声明
type golang interface{}
// 由main函数作为程序入口点启动
func main(){
Println("Hello World!")
}
(二)Go文件的基本组成部分
1. 包声明
2. 引入包
3. 函数
4. 变量
5. 语句 & 表达式
6. 注释
(三)Go文件结构组成
. , : ; ...
原文:https://www.cnblogs.com/hq82/p/12930319.html