go
dreams512
这个作者很懒,什么都没留下…
展开
-
go语言使用json
go语言使用json参考 https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/07.2.md解析jsonimport ( "fmt" "github.com/bitly/go-simplejson" "encoding/json" "github.com/bitly/g转载 2017-06-19 22:57:39 · 609 阅读 · 0 评论 -
golang中context的使用
context的使用 package main import "fmt" import ( "context" "time" ) func inc(a int) int { res := a+1 time.Sleep(1*time.Second) return res } func Add(ctx context.Context,a,b int) i...原创 2018-04-01 10:52:00 · 1404 阅读 · 0 评论 -
golang中channel的用法
go语言的range循环可以直接在channels上面迭代。使用range循环一次从channel中接受数据,当channel被关闭并且没有值可接受时跳出循坏。 func main() { natures := make(chan int) squares := make(chan int) go func() { for x := 0; x < ...转载 2018-04-01 14:05:33 · 2291 阅读 · 0 评论