Learn
Learn Go: Variables and Types
Review
In this lesson you learned:
- How to use literals in a Go program.
- How to create constants that give names to values.
- The basic types in Go:
int
s,float
s,complex
s, andstring
s. - The different numeric types and what values they accept.
- How to create variables in Go with a specific type.
- How to read an error in Go.
- How to assign values to variables using
=
. - How to create variables in Go with inferred type.
- How to declare multiple variables on a single line.
- The “zero” values for variables that haven’t been assigned a value yet.
- How Go decides the type for “default”
int
types depending on the architecture of the computer it’s running on. - How to update values in variables using
=
and other related operators.
What a lot of concepts! These tools will be very valuable to you along your journey as a programmer. Congratulations!
Instructions
If you want to challenge yourself more:
- Use Go’s
-=
,*=
,/=
operators to do some mathematical calculations. - Using variables to customize a greeting message for yourself and other users.
- Edit how the current variables are declared and initialized (but keep the same functionality).