25% off

Use code FUNCMAIN at checkout for 25% off all premium courses.

Get started โ†’

Interactive Go ยท Lesson

Types & Long-hand Variables

The := operator is handy, but sometimes you want to be explicit about a variable’s type. The long-hand form uses the var keyword followed by a name and a type:

var heroName string = "Aragorn"
var level int = 5
var alive bool = true
var damage float64 = 12.5

Go’s basic types include string, int, bool, and float64. If you declare a variable without a value, it takes that type’s zero value (0, "", or false).

Your Quest

Declare a bool variable named isReady set to true using the long-hand var form.

Expected output:

Aragorn is level 5 - ready: true

Hint

The pattern is var <name> <type> = <value>, e.g. var isReady bool = true.

Additional Scrolls of Wisdom