Welcome to the GoLang Exercises Directory! This repository is designed to provide a structured learning path covering all fundamental and advanced topics in Go. Each topic is accompanied by a dedicated exercise file with self-contained challenges to help reinforce your understanding of Go.
Each directory contains a main.go file with exercise prompts written as comments. Your task is to complete them without looking at references to strengthen your memory and problem-solving skills.
- Clone this repository:
git clone https://github.com/your-repo/golang-exercises.git cd golang-exercises - Run any exercise:
go run XX_topic/main.go
Note: Replace
XX_topicwith the actual folder name (e.g.,01_hello_world). - Use the provided
run.shscript to compile-check all exercises.
01_hello_world- Print your first message in Go02_variables- Working with variables and types03_strings- Manipulating strings and formatting04_numbers- Arithmetic, floating points, and precision05_arrays_slices- Working with arrays and slices06_maps- Key-value storage using maps07_structs- Defining and using structs08_control_flow- If statements, loops, and switches09_functions- Function definitions, return values, and recursion10_interfaces- Polymorphism and dynamic types
11_errors- Handling errors and creating custom errors12_enums- Simulating enums in Go13_concurrency- Goroutines, channels, and synchronization14_file_io- Reading/writing files efficiently15_http_server- Building a basic HTTP server16_pointers- Memory management with pointers17_json_handling- Parsing and generating JSON18_cli- Command-line applications and argument parsing19_regex- Pattern matching with regular expressions20_testing- Writing unit tests and benchmarks
21_reflection- Dynamic type inspection and modification22_generics- Using generics for flexible code23_context- Managing timeouts and cancellations24_middleware- HTTP middleware for logging, authentication, etc.25_grpc- Implementing gRPC services and clients26_dependency_injection- Using DI for clean architecture27_dbs- Connecting to databases and executing queries28_bits- Bitwise operations and optimizations29_time_date- Working with time, date, and timezones
30_string_performance- Efficient string manipulation31_file_strings- Handling large text files efficiently32_multilingual_strings- Processing Unicode and multilingual text33_string_encoding- Base64, hex, and URL encoding/decoding
We welcome contributions to expand this repository! Here’s how you can help:
- Fix typos, improve comments in exercises
- Add new topics that are useful for Go developers
- Suggest improvements for existing exercises
- Fork the repository
- Create a new branch:
git checkout -b feature/topic-improvement
- Commit changes and push:
git commit -m "Improved exercises for concurrency" git push origin feature/topic-improvement - Open a Pull Request with a clear description of your changes.
✔️ Reinforce core Go concepts with hands-on practice
✔️ Cover advanced topics that improve performance & scalability
✔️ Provide self-contained exercises for easy learning
✔️ Maintain idiomatic Go best practices
Happy Coding! 🎉