go-hello-world-学习

第一个go程序

helloworld.go

  package main
  import "fmt"
  func main() {
  	fmt.Println("vim-go")
    	fmt.Println("hello world!")
}

1 当前为main包,是程序的主入口包;
2 导入 fmt 包
3 程序执行入口 main 函数

  1. 使用 go run 执行以上代码
$ go run helloworld.go 
vim-go
hello world!
  1. 使用 go build 生成二进制文件
$ go build helloworld.go
$ ./helloworld 
vim-go
hello world!
  1. 代码链接,后续会有不断更新:
    https://github.com/DefangHe/go-study

你可能感兴趣的:(Go语言学习,go语言)