Variables and Data Types

Variables in Go are statically typed and can be declared using the var keyword or using short declaration syntax (:=).

var name string = "GoLang"
var age int = 10

// Short declaration
count := 5

Common data types in Go:

  • int, float64 - Numbers
  • string - Text
  • bool - Boolean
  • array, slice, map - Collections
← PrevNext →