Gaaker Go

Golang While loop

There is no while loop in Go.

But a for loop with only conditional expressions is equivalent to a while loop.

The following is a complete code example.

package main

import "fmt"

func main() {
	sum := 1
	for sum < 1000 {
		sum += sum

Below is the program output:

< While loop While loop >