package main import "fmt" func main() { var isSuccess bool fmt.Printf("布尔零值: %t\n", isSuccess) // 输出false a, b := true, false // 逻辑运算 fmt.Printf("a && b: %t\n", a && b) // false(与) fmt.Printf("a || b: %t\n", a || b) // true(或) fmt.Printf("!a: %t\n", !a) // false(非) // 条件判断中使用 score := 85 isPass := score >= 60 if isPass { fmt.Println("考试通过") // 输出此句 } // 错误示例(编译不通过) // var b bool = 1 // 报错:cannot use 1 (untyped int constant) as bool value in variable declaration // fmt.Println(b + 1) // 报错:invalid operation: b + 1 (mismatched types bool and untyped int) }