Introduction to Go Programming Language

Jul 2, 2024

Complete Go Course

Introduction

  • Young and popular programming language in cloud engineering.
  • Goal: Learn Go by building a simple CLI application.

Course Contents

  1. Motivation behind Go: Usage, differences, and characteristics.
  2. Setting up the Development Environment:
    • Installation of Visual Studio Code.
    • Installation of the Go compiler.
  3. Basic Structure of a Go File.
  4. Developing a Ticket Booking Application:
    • Common data types: strings, integers, booleans, arrays, slices, maps, structs.
    • Variables and constants.
    • Formatted output, user input, and validation.
    • Pointers and variable scopes.
    • Flow control: loops, if-else, and switch statements.
    • Function encapsulated logic.
    • Code organization in packages.
    • Concurrency with goroutines.

Motivation Behind Go

  • Developed by Google in 2007.
  • Motivation: Adapting to infrastructure improvements (multi-core, cloud).
  • Examples of Multithreading: Google Drive, YouTube.
  • Concurrency Issues: Avoid errors in parallel tasks.
  • Advantages of Go: Simplification in writing concurrent and multithreaded applications.
  • Main Feature: Easy writing of high-performance applications on modern scalable platforms.
  • Common Use: Backend, microservices, database services, and more.
  • Examples of technologies written in Go: Docker, Kubernetes, CockroachDB.
  • Simplicity and efficiency: Simple syntax, fast and resource-efficient applications.
  • Compiled Language: Fast compilation to a single binary, executable on different platforms.
  • Popularity in DevOps/SRE: Automation applications and CLI.

Setting up the Development Environment

  1. Installation of Visual Studio Code.
  2. Installation of the Go compiler.
  3. Preparing the environment in Visual Studio Code:
    • Creating a folder for the project.
    • Installation of necessary extensions for Go.

Creating the CLI Application

  1. Basic Structure of a Go File: main.go
  2. Welcome Message: