For is Go's "while"

At that point you can drop the semicolons: C's while is spelled for in Go.

for-is-gos-while.go

  1. package main
  2. import "fmt"
  3. func main() {
  4. sum := 1
  5. for sum < 1000 {
  6. sum += sum
  7. }
  8. fmt.Println(sum)
  9. }