fileName := "a.txt"
contents ,err := ioutil.ReadFile(fileName)
if err != nil{
fmt.Println("文件不存在")
}else{
fmt.Printf("%s\n",contents)
}
fileName := "a.txt"
if contents ,err := ioutil.ReadFile(fileName);err!=nil{
fmt.Println ( "file does not exist")
}else{
fmt.Printf("%s\n",contents)
}
Switch default language will go plus break
C 2 = var
Switch C {
Case. 1:
fmt.Print (C)
Case 2:
fmt.Print ( "Hello")
Case. 3:
fmt.Print ( "World")
default:
fmt.Println ( "the this IS The End" )
behind the switch can not follow the expression
var score = 80
switch {
case score >90 :
fmt.Print(score)
case score >80:
fmt.Print("hello")
case score >70:
fmt.Print("world")
default:
fmt.Println("this is the end")