Channel
Contoh #1
package main
import "fmt"
func test(value chan int) {
// channel out
result := 100 + <- value
fmt.Printf("%d ", result)
}
func main() {
fmt.Println("Start")
value := make(chan int)
for i := 0; i < 10; i++ {
go test(value)
// channel in
value <- i
}
fmt.Println("\nEnd")
close(value)
}Contoh 2
Contoh 3
Channel perlu di close
Last updated