很棒的go项目名单,带stars数
推荐
https://github.com/amanbolat/awesome-go-with-stars
Kubernetes Handbook——Kubernetes 中文指南/云原生应用架构实践手册
https://jimmysong.io/kubernetes-handbook/
Go设计模式实战 | 我的代码没有else系列
推荐
http://tigerb.cn/go-patterns/#/
GoF 23 种设计模式的 Go 实现
https://github.com/qiualiang/gof
AIOps在美团的探索与实践——故障发现篇
https://blog.csdn.net/weixin_45583158/article/details/109233962
https://tech.meituan.com/2020/10/15/mt-aiops-horae.html
源生静态资源内嵌方案
提前试用将在 Go1.16 中发布的内嵌静态资源功能
https://polarisxu.studygolang.com/posts/go/dynamic/go-embed-try/
go os/exec 简明教程
https://colobu.com/2020/12/27/go-with-os-exec/
并发编程-信号量的使用方法和其实现原理
https://mp.weixin.qq.com/s/QAMgkj-pDe36leDeGigu4Q
用法示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
package main import ( "context" "fmt" "sync" "time" "golang.org/x/sync/semaphore" ) func doSomething(u string) { // 模拟抓取任务的执行 fmt.Println(u) time.Sleep(2 * time.Second) } const ( Limit = 3 // 同時并行运行的goroutine上限 Weight = 1 // 每个goroutine获取信号量资源的权重 ) func main() { urls := []string{ "http://www.example.com", "http://www.example.net", "http://www.example.net/foo", "http://www.example.net/bar", "http://www.example.net/baz", } s := semaphore.NewWeighted(Limit) var w sync.WaitGroup for _, u := range urls { w.Add(1) go func(u string) { s.Acquire(context.Background(), Weight) doSomething(u) s.Release(Weight) w.Done() }(u) } w.Wait() fmt.Println("All Done") } |
转载请注明:轻风博客 » 整理的精彩文章-2021上