Go Development – 75+ Lab Exercises (Basic, Intermediate, Advanced)

🔰 Basic Level (25+ Exercises)

 

Goal: Master Go fundamentals, data structures, and file handling.

 

Setup and Hello World

  • Install Go and configure the environment.

  • Write, compile, and run a “Hello, World!” program.

Variables and Data Types

  • Declare variables of different types (int, string, bool).

  • Use constants and iota enumerations.

Control Structures

  • Implement if, else if, and else conditions.

  • Use for loops and switch statements.

Functions

  • Define simple functions.

  • Use multiple return values and named returns.

Arrays, Slices, and Maps

  • Create and manipulate arrays and slices.

  • Use maps for key-value storage.

Structs and Methods

  • Define structs and initialize them.

  • Add methods to structs.

Basic Error Handling

  • Return and check errors.

  • Use defer for cleanup tasks.

Basic File I/O

  • Read from and write to files.

Basic CLI Application

  • Parse command-line arguments.


 

🚀 Intermediate Level (30+ Exercises)

 

Goal: Build robust applications with concurrency, APIs, and testing.

 

Interfaces and Polymorphism

  • Define interfaces and implement them in structs.

  • Use empty interfaces and type assertions.

Concurrency Basics

  • Use Goroutines and channels.

  • Implement worker pools for parallel processing.

Package Management

  • Create and use custom packages.

  • Manage dependencies with Go Modules.

JSON and XML Handling

  • Marshal and unmarshal JSON and XML data.

HTTP Client and Server

  • Build a simple REST API server using net/http.

  • Make HTTP requests and handle responses.

Testing and Benchmarking

  • Write unit tests using the testing package.

  • Benchmark functions and analyze performance.

Error Wrapping and Custom Errors

  • Create custom error types.

  • Wrap and unwrap errors for deeper insights.

Context Package

  • Use context for cancellation and deadlines in Goroutines.

Logging

  • Implement structured logging for debugging and production.


 

🧠 Advanced Level (35+ Exercises)

 

Goal: Engineer scalable, secure, and high-performance Go applications.

 

Advanced Concurrency Patterns

  • Use select statement with multiple channels.

  • Use sync package: Mutex, WaitGroup, Once.

Reflection

  • Use the reflect package for dynamic type inspection and manipulation.

Building CLI Tools with Cobra/Viper

  • Create advanced CLI apps with command hierarchy and configuration management.

Database Integration

  • Connect to SQL databases (PostgreSQL, MySQL) using database/sql.

  • Use ORM libraries like GORM.

Middleware and Routing

  • Build custom middleware for HTTP servers.

  • Use advanced routers like Gorilla Mux or Echo.

Profiling and Performance Optimization

  • Use pprof to analyze CPU and memory usage.

  • Optimize slow or inefficient code paths.

GRPC Services

  • Define protobuf schemas.

  • Implement gRPC client and server in Go.

Security Practices

  • Implement JWT-based authentication.

  • Use TLS for secure communication.

Microservices Architecture

  • Design and build microservices using Go.

  • Implement service discovery and load balancing.

Deploying Go Applications

  • Cross-compile Go apps for different OS/architectures.

  • Containerize with Docker and deploy via Kubernetes.


 

Optional Tools & Platforms

 

  • GoLand, Visual Studio Code

  • Cobra, Viper, Gorilla Mux, Echo

  • PostgreSQL, MySQL, SQLite, Redis

  • Docker, Kubernetes, Prometheus, Grafana

  • Postman, Swagger, gRPC, Protobuf

Scroll to Top