CodeNest

Variables and Printf

Declare variables with var, or use := inside functions to declare and infer the type at once:

var count int = 3
name := "Gopher"      // string
ratio := 0.75         // float64

fmt.Printf formats values: %d int, %s string, %.2f float, %v anything. Add \n yourself.

Try it

Print:

Gopher was born in 2009
Go unavailable
Next
Running Go needs a server execution engine, which isn't configured on this deployment. You can still read the lesson and try the code locally.
Loading editor…

Press Ctrl/ + Enter or click Run to see the output here.