在Go中循环循环

Correct me if I'm wrong, there are only 3 types of loops in Go.

Type1 (The most basic type, with a single condition):

for i <= 3 {...}

Type2 (Classical for-loop)

for j := 7; j <= 9; j++ {...}

Type3 (infinite loop rely on break)

for {...break}

Then I come across this for loop that sums the value from array

nums := []int{2, 3, 4}
sum := 0
for _, num := range nums {
    sum += num
}
fmt.Println("sum:", sum)//"sum: 9"

Is the above for-loop to be considered Type1 where it automatically applies <= and range of nums as max value? Can I in any way change the value? maybe I need two extra loops? Can we apply something like range + 2?

From Effective Go:

The Go for loop is similar to—but not the same as—C's. It unifies for and while and there is no do-while. There are three forms, only one of which has semicolons.

// Like a C for
for init; condition; post { }

// Like a C while
for condition { }

// Like a C for(;;)
for { }

It continues:

If you're looping over an array, slice, string, or map, or reading from a channel, a range clause can manage the loop.

for key, value := range oldMap {
        newMap[key] = value
}

From this I think of range loops as a for condition { } loop, where the condition (such as it is) is that the variables being designated as the values of the array/slice/string/map/chan are not nil, though in practice even explicitly nil values work

for _, v := range []interface{}{nil, nil, nil, nil} {
    // will still iterate four times
}

In reality it might be more useful to think of Go's for loop as a contextual combination of a C-style for init; condition; post loop, a classical while loop, and a more modern foreach loop.

Type1 will work almost like while in other languages. Since there is no while in go language it uses for in that case.

Type2 is the classic for loop like in other languages as you have also stated.

Type3 is used to range over various data structures like arrays, slice, maps

range on arrays and slices provides both the index and value for each entry like the example you have given

nums := []int{2, 3, 4}
sum := 0
for _, num := range nums {
    sum += num
}
fmt.Println("sum:", sum)//"sum: 9"

range on map iterates over key/value pairs.

kvs := map[string]string{"a": "apple", "b": "banana"}
for k, v := range kvs {
    fmt.Printf("%s -> %s
", k, v)
}

range on strings iterates over Unicode code points. The first value is the starting byte index of the rune and the second the rune itself.

for i, c := range "go" {
    fmt.Println(i, c)
}

For more information, Check Go by example website for usage of range