全部 Go代码片段 Go Gin Go基础 Go Redis Pongo
常用库

switch的语法


package main

import (
"fmt"
"runtime"
)

func main() {
fmt.Print("Go runs on ")
switch os := runtime.GOOS; os {
case "darwin":
fmt.Println("OS X.")
case "linux":
fmt.Println("Linux.")
default:
// freebsd, openbsd,
// plan9, windows...
fmt.Printf("%s.\n", os)
}
}


编辑
Global Webdesign Awards 6.0 Index BLog Lib Login Cnzz 浙ICP备18000228号-2 chi@raffhk.com