@kjk1/

gobook channels close 3

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9163393527111854","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"CnBhY2thZ2UgbWFpbgoKaW1wb3J0ICgKCSJmbXQiCikKCmZ1bmMgbWFpbigpIHsKCS8vIDpzaG93IHN0YXJ0CgljaCA6PSBtYWtlKGNoYW4gaW50KQoJZ28gZnVuYygpIHsKCQljaCA8LSAxCgkJY2xvc2UoY2gpCgl9KCkKCXYsIGlzQ2xvc2VkIDo9IDwtY2gKCWZtdC5QcmludGYoInJlY2VpdmVkICVkLCBpcyBjaGFubmVsIGNsb3NlZDogJXZcbiIsIHYsIGlzQ2xvc2VkKQoJdiwgaXNDbG9zZWQgPSA8LWNoCglmbXQuUHJpbnRmKCJyZWNlaXZlZCAlZCwgaXMgY2hhbm5lbCBjbG9zZWQ6ICV2XG4iLCB2LCBpc0Nsb3NlZCkKCS8vIDpzaG93IGVuZAp9"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package main

import (
	"fmt"
)

func main() {
	// :show start
	ch := make(chan int)
	go func() {
		ch <- 1
		close(ch)
	}()
	v, isClosed := <-ch
	fmt.Printf("received %d, is channel closed: %v\n", v, isClosed)
	v, isClosed = <-ch
	fmt.Printf("received %d, is channel closed: %v\n", v, isClosed)
	// :show end
}