标签:int pack package ring string pre pac fun case
1. if else
package main import "fmt" func main(){ a :=123 if a>100{ fmt.prinln("大于100") }else{ fmt.println("小于100") } }
2. switch
例1
var shuxue int = 300 switch { case shuxue == 100: fmt.Println("111") case shuxue == 200: fmt.Println("222") default: fmt.Println("ok") }
例2
var marks int = 90 var grade string switch marks { case 90: grade = "A" case 80: grade = "B" default: grade = "D" } fmt.Println(grade)
标签:int pack package ring string pre pac fun case
原文地址:https://www.cnblogs.com/Jack-cx/p/10182529.html