Post

Go Mastery: A Comprehensive Guide - Part 1: Introduction, Variables, and Operators

Go Mastery: A Comprehensive Guide - Part 1: Introduction, Variables, and Operators

Introduction

Go (or Golang) is a statically typed, compiled programming language designed at Google. It’s renowned for its simplicity, efficiency, and excellent support for concurrency. Whether you are building cloud services, command-line tools, or high-performance backends, Go offers a perfect balance between performance and developer productivity.

Getting Started

To get started, ensure you have Go installed on your system. You can verify this by running:

1
go version

A simple “Hello, World!” program in Go:

1
2
3
4
5
6
7
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Variables

Go is statically typed. You can declare variables using var or the short declaration operator :=.

1
2
var name string = "Go"
age := 10 // Type inferred

Operators

1. Arithmetic Operators

+, -, *, /, %

2. Comparison Operators

==, !=, <, <=, >, >=

3. Logical Operators

&& (AND), || (OR), ! (NOT)

4. Bitwise Operators

& (AND), | (OR), ^ (XOR), &^ (AND NOT), << (Left shift), >> (Right shift)

Conclusion

We’ve covered the absolute basics: environment setup, variable declarations, and the common operators used in Go. In the next part, we will explore control flow statements like if/else, switch, and loops.

Suggested Reading

This post is licensed under CC BY 4.0 by the author.