https://www.lanqiao.cn/courses/485
https://gobyexample-cn.github.io/
https://gobyexample.com/
https://github.com/everyx/gobyexample
开发第一个 Go 程序 Hello World
我们的第一个程序将打印传说中的“hello world”, 右边是完整的程序代码。
package mainimport "fmt"func main() {fmt.Println("hello world")}
要运行这个程序,先将将代码放到名为 hello-world.go 的文件中,然后执行 go run。
~/Go by Example$ go run hello_world.go
hello world
如果我们想将程序编译成二进制文件(Windows 平台是 .exe 可执行文件), 可以通过 go build 来达到目的
然后我们可以直接运行这个二进制文件
~/Go by Example$ go build hello_world.go
~/Go by Example$ ls
hello_world hello_world.go
~/Go by Example$ ./hello_world
hello world
