go条件语句
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)