Start learning free

LESSON 10 OF 404 · VARIABLES

Data Types in Go

Lesson

Every value in Go has a type. The type tells Go what kind of data the value represents.

Common Go types include:

  • int for whole numbers, like 5
  • float64 for decimal numbers, like 3.14
  • string for text, like "Hello"
  • bool for truth values, true or false
var age int = 31
var price float64 = 9.99
var name string = "Andy"
var isStudent bool = true

Assignment
Follow the Coding Tutorial and create variables of different Go types.


Hint
Write the type after the variable name when using var.


STEP 1 OF 4
    Ctrl + Enter to check