初级会员
  • 第 13323 位会员
  • leavesdrift
  • 江成
  • 2017-10-17 02:55:54
  • Offline
  • 22 45

最近发布的文章

    暂无

最近分享的资源

    暂无

最近发布的项目

    暂无

最近的评论

  • 就是你说的 _method 这种,因为我没研究过具体是怎么实现的。所以想知道 go 中有类似的包么。
  • #6 @yinshidaoshi 这个是 go by example 上的例子,我是没找到好的用工作池的地方哈哈
  • 评论了主题 HTTPs SSL请求
    肯定是会显示不安全的,自签名证书需要客户点击确认接收该证书,连接才能建立,就像SSH第一次创建连接时也需要用户自己确认该公钥是否是目标主机的,只是说HTTPS有证书这个过程。然后我觉得这个是正常的,需要手动输入 https://
  • 工作池的作用并不是很明显,可以理解为限制 `Goroutine` 数,好处是传递任务方便,但是我觉得写不写都一样,没啥好处,你程序里的 id 有点不必要我感觉,这个是一个工作池的写法 ```go // In this example we'll look at how to implement // a _worker pool_ using goroutines and channels. package main import "fmt" import "time" // Here's the worker, of which we'll run several // concurrent instances. These workers will receive // work on the `jobs` channel and send the corresponding // results on `results`. We'll sleep a second per job to // simulate an expensive task. func worker(id int, jobs <-chan int, results chan<- int) { for j := range jobs { fmt.Println("worker", id, "started job", j) time.Sleep(time.Second) fmt.Println("worker", id, "finished job", j) results <- j * 2 } } func main() { // In order to use our pool of workers we need to send // them work and collect their results. We make 2 // channels for this. jobs := make(chan int, 100) results := make(chan int, 100) // This starts up 3 workers, initially blocked // because there are no jobs yet. for w := 1; w <= 3; w++ { go worker(w, jobs, results) } // Here we send 5 `jobs` and then `close` that // channel to indicate that's all the work we have. for j := 1; j <= 5; j++ { jobs <- j } close(jobs) // Finally we collect all the results of the work. for a := 1; a <= 5; a++ { <-results } } ```
  • 评论了主题 re2正则问题
    可以这样用: ``` `\p{Greek}` => '\u0370' - '\u03FF' 即 ‘Ͱ‘ 字符到 'Ͽ' `\p{Braille}` => '⢓⢔⢕⢖⢗⢘⢙⢚⢛' `\p{Cherokee}` => 'ᏯᏰᏱᏲᏳᏴ...' ``` 还有很多,只能说,没啥卵用。今天才发现golang正则支持的东西太少了,零宽断言也不支持。