Go Tutorial #16: Building REST APIs with Gin

In the previous tutorial, you built HTTP servers with the standard net/http package. That works great for simple servers. But as your API grows, you need better routing, input validation, and middleware support. Gin is the most popular Go web framework with over 80,000 GitHub stars. It is fast, well-documented, and used in production by thousands of companies. In this tutorial, you will learn how to build REST APIs with Gin. ...

April 11, 2026 · 8 min

Go Tutorial #15: Building HTTP Servers with net/http

In the previous tutorial, you learned advanced error handling patterns. Now it is time to build something real — an HTTP server. Go has a powerful HTTP server in the standard library. No framework needed. The net/http package gives you everything for building web servers and REST APIs. Many production Go services use only the standard library. Your First HTTP Server package main import ( "fmt" "net/http" ) func helloHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, World!") } func main() { http.HandleFunc("/hello", helloHandler) fmt.Println("Server starting on :8080") err := http.ListenAndServe(":8080", nil) if err != nil { fmt.Println("Server error:", err) } } Run it: ...

April 11, 2026 · 8 min

Go Tutorial #14: Error Handling Patterns — Beyond if err != nil

In Go Tutorial #4, you learned the basics of error handling — the error interface and the if err != nil pattern. Now it is time to go deeper. Real applications need more than basic error checks. You need to know what went wrong, where it went wrong, and how to handle different errors differently. Go gives you tools for all of this. Error Wrapping When a function calls another function and gets an error, you should add context before returning it. Use fmt.Errorf with the %w verb to wrap errors: ...

April 11, 2026 · 10 min

Go Tutorial #13: Select, Context, and Concurrency Patterns

In the previous tutorial, you learned about channels. Now you will learn how to work with multiple channels at the same time using select, how to cancel operations with context, and some powerful concurrency patterns. These are the tools that make Go concurrency practical for real applications. The select Statement select lets you wait on multiple channel operations at the same time. It blocks until one of the channels is ready: ...

April 11, 2026 · 9 min

Go Tutorial #12: Channels — Communication Between Goroutines

In the previous tutorial, you learned about goroutines. But goroutines alone are not enough. They need a way to communicate. That is what channels are for. Channels are typed pipes that connect goroutines. One goroutine sends a value into the channel, another goroutine receives it. Channels make concurrent programming safe and simple. Go has a famous saying: “Do not communicate by sharing memory. Share memory by communicating.” Channels are how you do that. ...

April 10, 2026 · 9 min

Go Tutorial #11: Goroutines — Lightweight Concurrency

In the previous tutorial, you learned how to organize a Go project. Now it is time for Go’s most powerful feature — goroutines. Goroutines are lightweight threads managed by the Go runtime. They are the reason Go is so popular for servers, microservices, and concurrent programs. You can run millions of goroutines on a single machine. What is a Goroutine? A goroutine is a function that runs concurrently with other goroutines. You start one with the go keyword: ...

April 10, 2026 · 8 min

Go Tutorial #10: Project Structure and Clean Architecture

In the previous tutorial, you learned about pointers. Now it is time to learn how to organize a Go project properly. Good project structure makes your code easy to read, test, and maintain. Go does not force a specific layout, but the community has developed clear conventions. This tutorial teaches you those conventions. Starting Simple — One Package When your project is small, keep it simple. A single main package is fine: ...

April 10, 2026 · 10 min

Go Tutorial #9: Pointers — Simple and Safe

In the previous tutorial, you learned about interfaces and polymorphism. Now it is time to learn about pointers — how Go lets you share and modify data efficiently. If you have used C or C++, you know pointers. Go pointers are simpler. There is no pointer arithmetic. You cannot do math on pointer addresses. This makes Go pointers safe and easy to understand. What is a Pointer? A pointer holds the memory address of a value. Instead of copying the value, you pass its address. This lets functions modify the original value: ...

April 10, 2026 · 10 min

Go Tutorial #8: Interfaces and Polymorphism

In the previous tutorial, you learned about structs, methods, and composition. Now it is time to learn about interfaces — one of Go’s most powerful features. Interfaces in Go are different from most languages. There is no implements keyword. If a type has the right methods, it automatically satisfies the interface. This is called implicit implementation. What is an Interface? An interface defines a set of method signatures. Any type that implements all those methods satisfies the interface: ...

April 9, 2026 · 9 min

Go Tutorial #7: Structs, Methods, and Composition

In the previous tutorial, you learned about slices and maps. Now it is time to learn how to create your own types with structs. Go does not have classes. Instead, it uses structs and methods. Structs hold data, and methods add behavior. This is simpler than class-based languages like Java or Python. Defining a Struct A struct groups related fields together: package main import "fmt" type User struct { Name string Email string Age int } func main() { // Create a struct with field names user1 := User{ Name: "Alex", Email: "alex@example.com", Age: 25, } fmt.Println(user1) // Access fields with dot notation fmt.Println("Name:", user1.Name) fmt.Println("Email:", user1.Email) // Update a field user1.Age = 26 fmt.Println("New age:", user1.Age) } Output: ...

April 9, 2026 · 8 min