---
title: "Discussion on \"Golang 实例 - channel的使用\" | Hashnode"
description: "Discussion on \"Golang 实例 - channel的使用\". 需求\n协程每隔1秒, 连续3次打印 [go routine] working on it. 然后把ping通过channel通知主线程任务完成. \n主线程接收到ping后, 打印 [main] All done, 然后程序退出.\n这个例子演示了 go channel 的简单使用.\n代码\npackage main\n\nimport (\n    \"fmt\"\n    \"time\"\n)\n\nfunc worker(chanWorker chan string) {\n\n    fmt.Printf(\"[go ..."
url: "https://hashnode.com/posts/golang-channel/643a18e7a50a6a3bb34d267d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Golang 实例 - channel的使用](https://fabiochen.hashnode.dev/golang-channel?utm_source=hashnode&utm_medium=feed)

需求 协程每隔1秒, 连续3次打印 \[go routine\] working on it. 然后把ping通过channel通知主线程任务完成. 主线程接收到ping后, 打印 \[main\] All done, 然后程序退出. 这个例子演示了 go channel 的简单使用. 代码 package main import ( "fmt" "time" ) func worker(chanWorker chan string) { fmt.Printf("\[go ...

Apr 15, 2023 · 1 min read · fabiochen.hashnode.dev  
Read the article

-   [#golang](https://hashnode.com/tag/golang)

## Written by

[Fabio Chen](https://hashnode.com/@fabiochen)

@fabiochen

  
[View profile](https://hashnode.com/@fabiochen)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
