Essential Go for, while loops  Edit on GitHub      File Issue

while loop

Go doesn’t have while loops.

for loop is powerful enough to express while loops.

For example, this C++ while loop:

int n = 0;
while (n < 3) {
    printf("n: %d\n", n);
    n++;
}

can be expressed as for loop:

for n := 0; n < 3; n++ {
    fmt.Printf("n: %d\n", n)
}
  ↑ ↓ to navigate     ↵ to select     Esc to close