Gaaker Go

Golang If statement

The following is the basic format of an if statement. If the condition is true, the statement inside the curly braces is executed.

if condition {
    // do something	

The following is a complete code example.

package main

import "fmt"

func main() {
    var str string
    if str == "" { 
        fmt.Println("The string is empty.")

Below is the program output:

The string is empty.
< If statement If statement >