Skip to content

harryosmar/go-training

Repository files navigation

Go Training for Beginners πŸš€

Welcome to Go Training! This repository is designed to help beginners learn Go programming from scratch with clear, easy-to-follow examples.

πŸ“‹ Table of Contents

πŸ”§ Installation

Step 1: Install Go

macOS

# Using Homebrew
brew install go

# Or download from official website
# Visit: https://go.dev/dl/

Linux

# Download and install
wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz

# Add to PATH (add to ~/.bashrc or ~/.zshrc)
export PATH=$PATH:/usr/local/go/bin

Windows

  1. Download the installer from https://go.dev/dl/
  2. Run the MSI installer
  3. Follow the installation wizard

Step 2: Verify Installation

go version

You should see output like: go version go1.21.5 darwin/amd64

Step 3: Set Up Your Workspace

# Check your GOPATH
go env GOPATH

# Create a workspace directory (if needed)
mkdir -p ~/go/src

πŸš€ Getting Started

Running Your First Program

  1. Navigate to any example folder

  2. Run the program:

    go run main.go
  3. Build an executable:

    go build main.go
    ./main

πŸ“š Examples Menu

Basic Concepts

  1. example1-hello-world - Your First Go Program

    • Basic program structure
    • Package declaration
    • Import statements
    • Main function
    • Print to console
  2. example2-variables-types - Variables and Data Types

    • Variable declaration
    • Basic data types (int, string, bool, float)
    • Type inference
    • Constants
    • Zero values
  3. example3-control-flow - Control Flow

    • If/else statements
    • Switch statements
    • For loops
    • Break and continue
  4. example4-functions - Functions

    • Function declaration
    • Parameters and return values
    • Multiple return values
    • Named return values
    • Variadic functions
  5. example5-arrays-slices - Arrays and Slices

    • Array declaration and usage
    • Slice basics
    • Slice operations (append, copy)
    • Slice iteration
  6. example6-maps - Maps (Hash Tables)

    • Map declaration
    • Adding and retrieving values
    • Checking key existence
    • Iterating over maps
    • Deleting keys
  7. example7-structs - Structs

    • Struct definition
    • Creating struct instances
    • Struct fields
    • Struct methods
    • Embedded structs
  8. example8-pointers - Pointers

    • Pointer basics
    • Address operator (&)
    • Dereference operator (*)
    • Pointers with functions
    • Pointers with structs

Advanced Concepts

  1. example9-context - Context Package

    • What is context and why it matters
    • Context cancellation
    • Context with timeout
    • Context with deadline
    • Passing values through context
    • Real-world use cases (HTTP, database, goroutines)
    • Best practices and patterns
  2. example10-clean-architecture - Clean Architecture

  • Production-ready REST API
  • Entity, DTO, Repository, UseCase, Handler layers
  • Dependency injection
  • Interface-based design
  • Unit testing with mocks
  • Idiomatic Go patterns
  1. example11-goroutines - Advanced Goroutines & Concurrency
  • Goroutines and concurrent execution
  • WaitGroup synchronization
  • Channels (buffered vs unbuffered)
  • Worker Pool pattern
  • Fan-Out Fan-In pattern
  • Pipeline pattern
  • Graceful shutdown
  • Retry logic and rate limiting
  • Reference: go-routine-patterns

πŸ“– How to Use This Guide

  1. Start from example1 and work your way through sequentially
  2. Read the README in each example folder for detailed explanations
  3. Run the code to see it in action
  4. Modify the code to experiment and learn
  5. Complete the exercises (if provided) to reinforce learning

Tips for Learning

  • πŸ’‘ Type the code yourself instead of copy-pasting
  • πŸ” Experiment by changing values and seeing what happens
  • πŸ“ Take notes on concepts that are new to you
  • πŸ› Debug errors - they're great learning opportunities
  • πŸ”„ Review previous examples if you get stuck

🎯 Learning Path

Start Here
    ↓
example1: Hello World (Basics)
    ↓
example2: Variables & Types (Data)
    ↓
example3: Control Flow (Logic)
    ↓
example4: Functions (Organization)
    ↓
example5: Arrays & Slices (Collections)
    ↓
example6: Maps (Key-Value Storage)
    ↓
example7: Structs (Custom Types)
    ↓
example8: Pointers (Memory)
    ↓
example9: Context (Cancellation & Timeouts)
    ↓
example10: Clean Architecture (Production Patterns)
    ↓
example11: Goroutines (Concurrency Patterns)
    ↓
Keep Learning! πŸŽ“

πŸ“š Additional Resources

Official Documentation

Community

Practice

🀝 Contributing

Found a bug or have a suggestion? Feel free to open an issue or submit a pull request!

πŸ“„ License

This project is open source and available for educational purposes.


Happy Learning! πŸŽ‰

Remember: Everyone starts as a beginner. Take your time, practice regularly, and don't be afraid to make mistakes!

About

πŸš€ Complete Go training repository with hands-on examples covering fundamentals to clean architecture - Perfect for beginners learning Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages