Go for Beginners — Part 3

Literals

In Go, values can be a lot of things. These can be written into code as is then they are literals as they literally are what they say they are

  • + to add
  • - to subtract
  • * to multiply
  • / to divide
  • % to find the remainder (Also known as the modulus operator)

Constants

There are also things called Constants which is a data type that can not be updated while the program is running.

const bruhMoment = "bruh"

Basic Data Types In Go

Whoooo kinda more advanced but not too advanced stuff now.

String

A String is a essential Data Type as it holds a string of characters such as this sentence. To define a String you use the string keyword

Integer

An Integer (int) is a whole number, simple as that. To define an Integer you use the keyword int

var bruh int
var bruh float
var bruh complex

Basic Numeric Data Types

This one is kinda important so pay attention!!

Variables

We have a little background on what the different Data Types, We can now start to create some.

Longhand Notation

var variableName type

Shorthand Notation

The other much quicker way is through Shorthand Notation which looks like this;

variableName := value

Zero Values

All variables unless assigned a value have a default value of zero

Summary

Thats a basic overview of Variables and Data Types within Go. In this Article i’ve briefly covered Variables within Go and gave you a brief look at different Data Types in Go.

--

--

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
Kodey Thomas

Kodey Thomas

Backend Developer, Probably listening to music and drinking coffee