Go — Values, Variables, and Constants (basics)

Go has several different value types, these are:

  • String
  • Integer
  • Float
  • Boolean
  • etc.

Here are some examples:

All these values can be assigned to a variable, and saved for later use. Go’s variables are explicitly declared, and the type and value are then used by the compiler to e.g. check for the correctness of types when comparing two variables, or for function calls.

Here are some examples of variables, and the initialization of variables:

For the last part of this article, I will go into “constants”. Constants are values, when initialized, which cannot be changed. In Go, you can initialize different types of constants: numeric, strings, and booleans.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nikolaj Johannes Skole Jensen

Fullstack developer living in Denmark. Experience with both Web- and App development.