一.规范目录结构
D:\project\src\go_dev\day1\example1
二.设置GOPAH环境变量
三.hello world
1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func main () { 8 fmt.Println("Hello World!") 9 }
go build go_dev\day1\example1
生成example1.exe
执行example1.exe
goroute循环
goroute.go
1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func test_goroute(a int) { 8 fmt.Println(a) 9 }
main.go
1 package main 2 3 import ( 4 "time" 5 ) 6 7 8 func main() { 9 10 for i :=0; i <100; i++ { 11 go test_goroute(i) 12 } 13 time.Sleep(2*time.Second) 14 }