Go語言 - switch/case

weixin_33670713發表於2018-01-12
# cat switch.go
package main

import "fmt"

func main() {
    i := 2
    switch i {
    case 1:
        fmt.Println("one")
    case 2:
        fmt.Println("two")
    case 3:
        fmt.Println("three")
    }
}
# go run switch.go
two

參考
https://gobyexample.com/switch

相關文章