Kanallarda Select / Case Kullanımı
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
kanalim := make(chan string) | |
go func() { | |
kanalim <- "mesaj" | |
}() | |
select { | |
case msg := <-kanalim: | |
fmt.Println(msg) | |
default: | |
fmt.Println("mesaj yok") | |
} | |
<-time.After(time.Second * 1) | |
select { | |
case msg := <-kanalim: | |
fmt.Println(msg) | |
default: | |
fmt.Println("mesaj yok") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment