What are Go's rules for comparing bytes with runes?
问题 I've discovered the following peculiarity: b := "a"[0] r := 'a' fmt.Println(b == r) // Does not compile, cannot compare byte and rune fmt.Println("a"[0] == 'a') // Compiles and prints "true" How does this work? 回答1: This is an example of untyped constants. From the docs: Untyped boolean, numeric, and string constants may be used as operands wherever it is legal to use an operand of boolean, numeric, or string type, respectively. Except for shift operations, if the operands of a binary