> For the complete documentation index, see [llms.txt](https://derslik.kerteriz.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://derslik.kerteriz.net/go/temel-dersler/go-doengueler/go-for-doenguesue.md).

# # Go For Döngüsü

Go programlama dilinde bir dizi veya belirlediğiniz iki sayı arasında döngü oluşturmak istediğinizde **for** terimini kullanırsınız. Programlama da önemli bir yeri olan **for** için örnek kullanımları hemen görelim.&#x20;

## 1. While Tarzı Döngü Oluşturmak

İlk örneğimizde diğer programla dillerinde yer alan **while** döngüsüne benzer bir kullanım ile bir aralıkta döngüyü çevirebiliriz.

```go
package main

import "fmt"

func main() {
	deger := 0
	for deger < 5 {
		fmt.Println(deger)
		deger++
	}
}
```

## 2. İki Sayı Arasında Döngü Oluşturmak

Belirlenen iki sayı arasında da döngü ayarlayabiliriz.

```go
package main

import "fmt"

func main() {
	for i := 0; i < 10; i++ {
		fmt.Println(i)
	}
}
```

## 3. Dizi Elemanları Üzerinde Döngü Oluşturmak

Elimizde olan bir liste üzerinde de `for` döngüsüyle gezinerek elemanlarını ekrana yazdırabiliriz.

```go
package main

import "fmt"

func main() {

	var sehirler []string = []string{"Ankara","İstanbul","Kayseri"}

	for i := 0; i < len(sehirler); i++ {
		fmt.Println(sehirler[i])
	}

}
```

## 4. For Döngüsünü Durdurma

Döngümüz ilerlerken istediğimiz bir durumda durdurabilmek için **break** komutunu kullanırız. Go **break** komutunu gördüğünde döngüyü durdurarak döngüden çıkar.

```go
package main

import "fmt"

func main() {

	var sayilar []int = []int{1,2,3,4,5}

	for i := 0; i < len(sayilar); i++ {
		
		if i == 1 {
			break
		}
	
		fmt.Println(sayilar[i])
	}

}
```

## 5. For Döngüsünde Atlama Yapmak

Döngümüzü bir koşul ile durdurabileceğimizi gördük. Şimdi ise yine bir koşul ile döngüde ki o durumu atlayabiliriz ve döngünün diğer aşamasına geçebiliriz. Bunun için **continue** terimini kullanabiliriz.

```go
package main

import "fmt"

func main() {

	var sayilar []int = []int{1,2,3,4,5}

	for i := 0; i < len(sayilar); i++ {
		
		if i == 1 {
			continue
		}
	
		fmt.Println(sayilar[i])
	}

}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://derslik.kerteriz.net/go/temel-dersler/go-doengueler/go-for-doenguesue.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
