🐹 Go (Golang) Programming Fundamentals

Master Google's fast, simple, and reliable programming language for modern software development

← Back to Programming Courses

Go Programming Curriculum

18
Go Units
~120
Core Concepts
Go 1.21
Latest Version
Fast & Simple
By Design
1

Go Introduction

Learn the fundamentals of Go and its design philosophy.

  • What is Go?
  • History and creators (Google)
  • Go design principles
  • Compiled vs interpreted
  • Cross-platform compilation
  • Setting up Go environment
  • Go workspace and modules
  • First Go program
2

Basic Syntax & Structure

Master the fundamental syntax and program structure of Go.

  • Go program structure
  • Package declaration
  • Import statements
  • Main function
  • Comments
  • Naming conventions
  • Code formatting (gofmt)
  • Build and run commands
3

Variables & Types

Work with Go's static type system and variable declarations.

  • Variable declaration
  • Short variable declaration (:=)
  • Basic types (int, string, bool)
  • Type inference
  • Constants
  • Zero values
  • Type conversions
  • Pointers
4

Control Flow

Control program execution with Go's control structures.

  • if statements
  • if with initialization
  • switch statements
  • Type switches
  • for loops
  • Range loops
  • Break and continue
  • Goto statements
5

Functions

Create reusable code with Go's function system.

  • Function declaration
  • Parameters and arguments
  • Return values
  • Multiple return values
  • Named return values
  • Variadic functions
  • Anonymous functions
  • Closures
6

Arrays & Slices

Work with Go's array and slice data structures.

  • Array declaration and initialization
  • Array literals
  • Slice fundamentals
  • Slice literals
  • make() function
  • append() function
  • Slice operations
  • Slice internals
7

Maps & Structs

Work with key-value maps and custom data structures.

  • Map declaration and initialization
  • Map operations
  • Testing for key existence
  • Struct definition
  • Struct literals
  • Struct fields
  • Embedded structs
  • Struct methods
8

Pointers & Memory

Understand memory management and pointer usage in Go.

  • Pointer basics
  • Address operator (&)
  • Dereference operator (*)
  • Pointer to structs
  • Pointer arithmetic (lack thereof)
  • new() function
  • Memory allocation
  • Garbage collection
9

Methods & Interfaces

Create methods and implement Go's interface system.

  • Method declaration
  • Receiver types
  • Pointer receivers
  • Interface definition
  • Interface implementation
  • Empty interface
  • Type assertions
  • Interface composition
10

Error Handling

Handle errors gracefully with Go's error handling approach.

  • Error interface
  • Creating errors
  • Error handling patterns
  • Custom error types
  • Error wrapping
  • panic() and recover()
  • defer statements
  • Best practices
11

Packages & Modules

Organize code with packages and manage dependencies with modules.

  • Package fundamentals
  • Package visibility
  • init() functions
  • Go modules
  • go.mod file
  • Dependency management
  • Versioning
  • Publishing packages
12

Goroutines & Concurrency

Master Go's powerful concurrency model with goroutines.

  • Goroutine basics
  • go keyword
  • Concurrent execution
  • Goroutine scheduling
  • Race conditions
  • Synchronization
  • WaitGroups
  • Context package
13

Channels

Communicate between goroutines using channels.

  • Channel basics
  • Channel creation
  • Sending and receiving
  • Buffered channels
  • Channel directions
  • select statement
  • Channel closing
  • Channel patterns
14

Standard Library

Explore Go's rich standard library packages.

  • fmt package
  • strings package
  • strconv package
  • time package
  • math package
  • os package
  • io package
  • Common utilities
15

File I/O & JSON

Handle file operations and JSON data processing.

  • File reading and writing
  • Working with directories
  • File permissions
  • JSON encoding
  • JSON decoding
  • Struct tags
  • Custom marshaling
  • Error handling
16

HTTP & Web Programming

Build web applications and REST APIs with Go.

  • HTTP package
  • HTTP handlers
  • HTTP server
  • HTTP client
  • Routing
  • Middleware
  • Templates
  • REST API development
17

Testing & Benchmarking

Test and benchmark Go applications effectively.

  • testing package
  • Writing unit tests
  • Test functions
  • Table-driven tests
  • Benchmarks
  • Examples
  • Test coverage
  • Testing best practices
18

Production & Deployment

Deploy Go applications to production environments.

  • Building executables
  • Cross-compilation
  • Build constraints
  • Optimization techniques
  • Containerization (Docker)
  • Monitoring and logging
  • Performance profiling
  • Deployment strategies

Unit 1: Go Introduction

Learn the fundamentals of Go and its design philosophy

What is Go?

Go is a statically typed, compiled programming language designed at Google.

Key Features: Fast compilation, Garbage collection, Concurrency support, Simple syntax

Go Architecture

Understanding Go's compilation and runtime architecture.

Go Source Code (.go)
Go Compiler & Runtime
Native Machine Code

Development Environment

Setting up your Go development environment.

Download Go from golang.org
Set GOPATH and GOROOT
VS Code with Go extension

First Go Program

Write and run your first Go application.

package main import "fmt" func main() { fmt.Println("Hello, Go!") }
Click 'Build & Run' to see output

Unit 2: Basic Syntax & Structure

Master the fundamental syntax and program structure of Go

Program Structure

Understanding the basic structure of a Go program.

Every Go program starts with a package declaration and imports

Packages and Imports

Organizing code with packages and importing functionality.

package main
import "fmt"

Naming Conventions

Go naming conventions and visibility rules.

Exported: CapitalCase
Unexported: camelCase
Constants: CamelCase or UPPER_CASE

Build Process

How Go source code becomes executable binaries.

.go files
go build
executable

Unit 3: Variables & Types

Work with Go's static type system and variable declarations

Basic Types

Go's fundamental data types for type safety.

bool string int int8 int16 int32 int64 uint

Variable Declaration

Different ways to declare variables in Go.

Click to see variable examples

Zero Values

Default values for uninitialized variables.

Go initializes variables to their zero value: 0, false, "", nil

Pointers

Working with memory addresses and pointers.

Pointers allow efficient memory usage and reference passing

Unit 4: Control Flow

Control program execution with Go's control structures

If Statements

Conditional execution with if statements.

if x > 0 { fmt.Println("Positive") } else if x < 0 { fmt.Println("Negative") } else { fmt.Println("Zero") }

Switch Statements

Multi-way branching with switch statements.

Go's switch doesn't fall through by default - no break needed

For Loops

Go's only looping construct - the for loop.

for init; condition; post { } - traditional C-style loop

Range Loops

Iterating over collections with range.

Use range for iterating over slices, maps, channels, and strings

Unit 5: Functions

Create reusable code with Go's function system

Function Declaration

Defining functions with parameters and return values.

func add(x int, y int) int { return x + y } func swap(x, y string) (string, string) { return y, x }

Multiple Return Values

Functions can return multiple values in Go.

Multiple returns are commonly used for value, error patterns

Variadic Functions

Functions that accept variable number of arguments.

func sum(nums ...int) int - variadic parameter syntax

Closures

Anonymous functions that capture variables from their scope.

Closures can access and modify variables from outer scope

Unit 6: Arrays & Slices

Work with Go's array and slice data structures

Arrays

Fixed-size sequences of elements in Go.

var arr [5]int arr[0] = 10 // Array literal numbers := [3]int{1, 2, 3}

Slices

Dynamic arrays that can grow and shrink.

Click to see slice operations

Slice Operations

Common operations like append, copy, and slicing.

Slices are references to underlying arrays with length and capacity

Slice Internals

Understanding how slices work under the hood.

Slices have a pointer, length, and capacity - understand memory implications

Unit 7: Maps & Structs

Work with key-value maps and custom data structures

Maps

Key-value pairs for associative data storage.

m := make(map[string]int) m["key"] = 42 // Map literal ages := map[string]int{ "Alice": 31, "Bob": 34, }

Structs

Custom types that group related data together.

Click to see struct definition

Struct Embedding

Composition through struct embedding.

Embedded structs provide a form of inheritance in Go

Struct Tags

Metadata for struct fields used by reflection.

Tags are commonly used for JSON serialization and validation

Unit 8: Pointers & Memory

Understand memory management and pointer usage in Go

Pointer Basics

Working with memory addresses in Go.

var p *int i := 42 p = &i fmt.Println(*p) // read i through pointer p *p = 21 // set i through pointer p

Pointer to Structs

Using pointers with struct types for efficiency.

Pointer receivers avoid copying large structs

Memory Allocation

How Go manages memory allocation and deallocation.

Go uses garbage collection for automatic memory management

new() Function

Allocating zeroed memory with the new() function.

new(T) allocates zeroed storage for T and returns *T

Unit 9: Methods & Interfaces

Create methods and implement Go's interface system

Methods

Functions with receiver arguments attached to types.

type Vertex struct { X, Y float64 } func (v Vertex) Abs() float64 { return math.Sqrt(v.X*v.X + v.Y*v.Y) }

Interfaces

Defining contracts that types must satisfy.

Click to see interface definition

Interface Implementation

Implicit interface satisfaction in Go.

Interface Definition
Implicit Implementation

Empty Interface

interface{} can hold values of any type.

Use empty interface sparingly - prefer specific interfaces when possible

Unit 10: Error Handling

Handle errors gracefully with Go's error handling approach

Error Interface

Go's built-in error interface for error handling.

type error interface { Error() string } // Usage result, err := someFunction() if err != nil { log.Fatal(err) }

Creating Errors

Different ways to create and return errors.

Use errors.New() or fmt.Errorf() to create simple errors

Panic and Recover

Handling exceptional situations with panic and recover.

Use panic/recover sparingly - prefer explicit error handling

Defer Statements

Ensuring cleanup code runs with defer.

defer statements execute in LIFO order when function returns

Unit 11: Packages & Modules

Organize code with packages and manage dependencies with modules