一.规范目录结构

D:\project\src\go_dev\day1\example1

二.设置GOPAH环境变量

三.hello world

1.hello world

 package main

 import (
"fmt"
) func main () {
fmt.Println("Hello World!")
}

go build go_dev\day1\example1

生成example1.exe

执行example1.exe

2.goroute循环

goroute.go

 package main

 import (
"fmt"
) func test_goroute(a int) {
fmt.Println(a)
}

main.go

 package main

 import (
"time"
) func main() { for i :=; i <; i++ {
go test_goroute(i)
}
time.Sleep(*time.Second)
}

3.goroute_example

代码目录结构

 package goroute

 func Add(a int, b int, c chan int) {
sum := a + b
c <- sum }

add.go

 package main

 import (
"go_dev/day1/goroute_example/goroute"
"fmt"
) func main() {
//var pipe chan int
//pipe = make(chan int, 1) pipe := make(chan int, ) //等同于上二行
go goroute.Add(, , pipe) sum := <- pipe
fmt.Println("sum =", sum)
}

main.go

构建代码

D:\project>go build -o bin/goroute_example.exe go_dev/day1/goroute_example/main

D:\project\bin>goroute_example.exe
sum = 400

  

最新文章

  1. linux 卸载编译安装的软件
  2. Linux下设置环境变量
  3. php页面编码与字符操作
  4. Power-BI 预警触发的设定
  5. 上传图片预览设置src不显示
  6. [CareerCup] 10.5 Web Crawler 网络爬虫
  7. oracle linux 下卸载
  8. cssText在 IE6/7/8和chrome/Firefox/IE9+的不同
  9. 用rem来做响应式开发
  10. 美化select的jquery插件
  11. 微信jsapi支付的坑
  12. 深入浅出AQS之共享锁模式
  13. RabbitMQ可靠性投递及高可用集群
  14. C++中int与string的相互转换【转】
  15. Elasticsearch基本用法(2)--Spring Data Elasticsearch
  16. 去7JAVA
  17. Centos 7 安装 Redis 3.2
  18. Flexbox指南
  19. Volley的Get、Post方式(JsonObjectRequest、StringRequest)以及Volley获取图片的3种方式
  20. spring boot读取配置文件

热门文章

  1. RHEL7配置中文输入法-智能拼音
  2. How an SSL connection is established
  3. Mysql 之show status数据详解
  4. php 在Linux下的安装
  5. Mysql 在Linux下的安装
  6. std::vector遍历
  7. centos 7 配置nginx
  8. centos添加永久的环境变量
  9. day41 网络编程
  10. Unittest加载执行用例的方法总结