Go If Statement
# Go Language if Statement
[ Go Conditional Statements](#)
An if statement consists of a Boolean expression followed by one or more statements.
### Syntax
The syntax of an if statement in Go programming language is:
if Boolean expression { /* Executes when the Boolean expression is true */ }
If the Boolean expression evaluates to true, the block of code inside the if statement is executed. If it evaluates to false, the block is not executed.
The flowchart is as follows:

### Example
Use if to check the size of a number variable:
## Example
package main
import"fmt"
func main(){
/* Define local variables */
var a int=10
/* Use if statement to check the Boolean expression */
if a <20{
/* If the condition is true, execute the following statement */
fmt.Printf("a is less than 20n")
}
fmt.Printf("a value is : %dn", a)
}
The output of the above code is:
a is less than 20 a value is : 10
[ Go Conditional Statements](#)
YouTip