OneBite.Dev - Coding blog in a bite size

use a conditional to check greater than number in Go

Code snippet on how to use a conditional to check greater than number in Go

  package main 

import "fmt"

func main() {
  
  //This code checks if the value of "x" is greater than 10. 
  x := 9
  if x > 10 {
    fmt.Println("x is greater than 10")
  }
}

This code starts by importing the language package called “fmt”, which stands for “format”. It allows us to print certain values to the console. Next, a new variable called “x” is declared and set to a value of 9. Following that, a conditional statement is used to check if the value of “x” is greater than 10. If so, it will print “x is greater than 10” to the console. If it is not, the code will simply move on to the next section.

go