From 9262520ce632493a8d4b17db46e06d596b9a0c4e Mon Sep 17 00:00:00 2001 From: Shikong <919411476@qq.com> Date: Sun, 12 Sep 2021 20:34:47 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20Boolean=20=E5=B8=83=E5=B0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/boolean/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 base/boolean/main.go diff --git a/base/boolean/main.go b/base/boolean/main.go new file mode 100644 index 0000000..546cb6a --- /dev/null +++ b/base/boolean/main.go @@ -0,0 +1,13 @@ +package main + +import "fmt" + +func main() { + // 在 golang 中 不允许 从其他类型 强制转换 到 bool 类型 + b1 := true + // bool 默认为 false + var b2 bool + + // %T 打印变量类型 + fmt.Printf("b1: %T %t\nb2: %T %t\n", b1, b1, b2, b2) +}