OneBite.Dev - Coding blog in a bite size

declare an integer in Go

Code snippet on how to declare an integer in Go

  package main 
  import "fmt"
  func main() {
    var number int 
    fmt.Println("Number =", number)
  }

This code declares an integer called number. The code begins by including two packages, main and fmt, which are required to use other functions. The keyword “var” is then used to initiate the integer, followed by the name. Finally, the Println function from the fmt package is used to show the result of “number” which is 0. This code shows the most basic way of declaring an integer in Go.

go