goto

Tutorial: Go初级 Category: Go Published: 2026-04-07 13:58:26 Views: 21 Likes: 0 Comments: 0
package main

import (
    "fmt"
    "strconv"
)

func logger(s string) {
    fmt.Println(s)
}

func main() {
    for i := 0; i < 10; i++ {
        for j := 'A'; j < 'Z'; j++ {
            logger(strconv.Itoa(i) + "-" + string(j))
            if j == 'C' && i == 1 {
                goto over
            }
        }
    }

over:
    logger("over")
}
Prev: switch Next: array