19 lines
227 B
Go
19 lines
227 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
func writeToChannel(c chan int, x int) {
|
|
fmt.Println(x)
|
|
c <- x
|
|
close(c)
|
|
fmt.Println(x)
|
|
}
|
|
|
|
func main() {
|
|
c := make(chan int)
|
|
go writeToChannel(c, 10)
|
|
time.Sleep(1 * time.Second)
|
|
}
|