Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fae5acd

Browse files
1.2.2 不发送数据的信道
1 parent 92c8846 commit fae5acd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package datastructure
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
)
7+
8+
func worker(ch chan struct{}) {
9+
<-ch
10+
fmt.Println("do something")
11+
}
12+
13+
func TestChannelWithoutData(t *testing.T) {
14+
ch := make(chan struct{})
15+
go worker(ch)
16+
ch <- struct{}{}
17+
close(ch)
18+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /