上QQ阅读APP看书,第一时间看更新
Boolean
The Boolean type represents a true or false value. Some languages don't provide a bool type, and you have to use an integer or define your own enumeration, but Go conveniently comes with a predeclared bool type. The true and false constants are also predefined and used in all lowercase. Here is an example of creating a Boolean:
var customFlag bool = false
The bool type is not unique to Go by any means, but one interesting piece of trivia about the Boolean type is that it's the only type named after a person. George Boole lived from 1815 to 1864 and wrote The Laws of Thought, where he described Boolean algebra, which is what all digital logic is based upon. The bool type is very simple in Go, but the history behind the name is very rich.