# Select

Go dilinde, `select` anahtar kelimesi, birden fazla `channel`'ı dinleyerek, hangi `channel`'ın mesaj gönderdiğini belirleyebilir. Bu özellik, `channel`'ların senkronizasyonunu kolaylaştırır ve farklı `goroutines` arasındaki mesajlaşmayı yönetir.

```go
package main

import (
	"fmt"
	"time"
)

func main() {
	c1 := make(chan string)
	c2 := make(chan string)

	go func() {
		time.Sleep(time.Second * 1)
		c1 <- "one"
	}()

	go func() {
		time.Sleep(time.Second * 2)
		c2 <- "two"
	}()

	for i := 0; i < 2; i++ {
		select {
		case msg1 := <-c1:
			fmt.Println("received", msg1)
		case msg2 := <-c2:
			fmt.Println("received", msg2)
		}
	}
}
```

Bu örnekte, `c1` ve `c2` adlı iki `channel` oluşturulur ve mesaj gönderme işlemi için `goroutine`'lar oluşturulur.

`main` fonksiyonunda, `select` anahtar kelimesi kullanılarak, `c1` ve `c2` `channel`'ları dinlenir. İlk olarak, `goroutine`'lar arasındaki bekleme süresi nedeniyle, `c1` `channel`'ından bir mesaj alınır ve ekrana yazdırılır. Daha sonra, `c2` `channel`'ından bir mesaj alınır ve ekrana yazdırılır.

Çıktı:

```
received one
received two
```

Bu örnekte, `select` anahtar kelimesi kullanarak, `c1` ve `c2` `channel`'larını dinleyen bir `for` döngüsü oluşturuldu. Bu, mesaj alım süresine bağlı olarak farklı `channel`'ların dinlenmesini sağlar. Sonuç olarak, `goroutine`'lar arasındaki mesajlaşma, belirli bir sıraya göre gerçekleştirilir ve `select` anahtar kelimesi kullanarak senkronizasyon sağlanır.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.furkangulsen.com/golang-dokumani/select.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
