第一个go程序
helloworld
//helloworld.go
package main
import "fmt"
func main() {
fmt.Println("HelloWorld")
}
- Go语言使用C++风格的注释:// 表示单行注释,/* */ 表示多行注释
- 每个Go程序都必须包含一个main包(package main) 和一个main函数(func main)
- import语句类似于C/C++里的 #include, fmt包提供输入输出函数
- 函数用关键字func定义,其中,main()函数没有参数也没有返回值
- Print(), Println(), Printf()均为fmt包里的函数,Println("…")等价于Print("…\n"), Printf()则提供标准化输出