执行Go程序的三种方式及Go语言关键字

时间:2023-03-09 06:21:02
执行Go程序的三种方式及Go语言关键字

执行 Go 程序的三种方式及 Go 语言关键字

执行 Go 程序的三种方式

一、使用 go run 命令

执行Go程序的三种方式及Go语言关键字

二、使用 go build 命令

Step1. 对 go 源码源文件执行 go build 命令,会生成一个同名 .exe的可执行文件

Step2. 执行.exe可执行文件

执行Go程序的三种方式及Go语言关键字

三、在线编译运行

使用官方网站的在线工具进行编译运行:https://play.golang.org

Go 语言中的关键字

Go 语言关键字

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

除了以上的关键字,Go 语言还有36个预定义标识符

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
print println real recover string true uint uint8 uintptr