DEV Community

Allison Yuri
Allison Yuri

Posted on

Hands-on Go — Advancing with Practical Examples

👋 Hello, everyone!

After the first post covering the initial four examples in gostart, I've added four more use cases that mirror real-world challenges you'll face with Go. Let's dive into what's been added!


📂 Updated Structure

gostart
┣ exemplos
┃ ┣ 01_hello
┃ ┣ 02_arguments
┃ ┣ 03_duplicates
┃ ┣ 04_animated_gif
┃ ┣ 05_http_requests
┃ ┣ 06_concurrency_channels
┃ ┣ 07_file_manipulation
┃ ┗ 08_api_integration
┗ README.MD
Enter fullscreen mode Exit fullscreen mode

Each folder contains a main.go and a README.md that walks you through the steps.

✅ 05 - HTTP Requests

What was added:

  • Consuming REST APIs with GET and POST
  • JSON handling (json.Marshal / json.Unmarshal)
  • Using http.NewRequest and customizing headers
  • Configuring http.Client with a timeout

Why it matters:
In real applications, you'll fetch and send data to external services—so mastering HTTP requests is essential.

✅ 06 - Concurrency & Channels

What was added:

  • Spawning goroutines for parallel tasks
  • Communicating via channels (buffered and unbuffered)
  • Synchronizing with sync.WaitGroup
  • Multiplexing channels with select and default
  • A worker pool pattern

Why it matters:
Go is built for concurrency—these examples show you how to scale work safely and efficiently.

✅ 07 - File Manipulation

What was added:

  • Reading and writing text and binary files (os, bufio, io)
  • Copying files with io.Copy
  • Processing CSV (encoding/csv) and JSON (encoding/json)
  • Walking directories and gathering metadata (filepath.WalkDir, os.DirEntry)

Why it matters:
Backend logic often involves file I/O—whether logs, data imports, or configuration files.

✅ 08 - API Integration

What was added:

  • Structuring a custom API client with an interface for easy testing
  • Authentication via headers (API Key / Bearer Token)
  • Timeout and cancellation control with context
  • Exponential backoff retry on 5xx errors
  • Robust error handling with wrapped context

Why it matters:
In corporate projects, you'll integrate with paid or internal services—these patterns are production-grade.

🚀 How to Get Started

  1. Clone the repository or update your fork:
git clone https://github.com/TheZehel/gostart.git
cd gostart/exemplos
Enter fullscreen mode Exit fullscreen mode
  1. Choose one of the new directories (05_http_requests, 06_concurrency_channels, etc.)

  2. Read the README.md to understand the flow, then run:

go run main.go
Enter fullscreen mode Exit fullscreen mode

🤝 Contributions

Want to help enrich gostart?

  • Create a folder 0X_example_name/ following the same convention
  • Include main.go with well-commented code and README.md with clear explanations
  • Suggested topics: databases, gRPC, interactive CLIs, automated tests, microservices…
  • Open a PR and let's grow this repository together! 💪

💬 Questions, suggestions, or feedback? Leave a comment below.

Let's keep learning by doing! 🚀

Top comments (0)