Topic Overview and Goal Setting

Greetings! As we venture into our Go Programming Expedition, we're setting out to understand Go Variables, our essential assistants. Similar to coordinates on a map, variables guide our code, endowing it with data and meaning.

In simple terms, a variable in coding is akin to a ticket — a reserved place in memory where a value can be stored. This lesson aims to demystify the concept of Go variables, examining their definition, naming conventions, assignment operations, and the concept of constant variables.

What are Go Variables?

Think of Go variables as tickets, each carrying specific data. The following short example illustrates how a variable is defined in Go:

Here, int is the data type of the variable (integer), numOfMountainPeaks is the variable's name, and 14 is its value. We will delve deeper into data types in the upcoming lesson, so don't fret if the int part is somewhat unclear now.

Alternatively, you can declare and assign the variable in one step like this:

Or using a short declaration:

To sum up, here are all the ways to initialize a variable:

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal