Operator and syntax

Go logical operators

Boolean AND and OR evaluate the right operand only when necessary. Unary ! negates a boolean. Numeric values do not substitute for booleans. Example output: 'false true false'.

Formal Syntax & Structure

go syntaxgo
&& || !

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  n := 0  fmt.Println(n != 0 && 10/n > 1, n == 0 || 10/n > 1, !(n == 0))}
Go Reference