Go for backend developers: web services with net/http

Build a clean, fast JSON API with the Go standard library: routing, middleware, PostgreSQL, context, testing and graceful shutdown

7 ratings 1,580 students Sample

Created by Leila Haddad

  • Updated September 2026
  • English
  • Intermediate

What you will learn

  • Structure a Go service into clear packages with a small main function
  • Route requests with net/http method and path patterns
  • Write middleware for logging, panics, request IDs and auth
  • Query PostgreSQL with pgx and generate type safe code with sqlc
  • Propagate deadlines and cancellation with context
  • Test handlers with httptest and ship a binary in a minimal container

Course content

5 sections, 24 lessons, 4h 6m total

Go services from the ground up 5 lessons · 53 min
  • Video: Why Go for web services Preview 8 min
  • Article: Go refresher for service code Preview 14 min
  • Article: Routing with the standard ServeMux 13 min
  • Article: JSON in and out, safely 13 min
  • Quiz: Check your understanding 5 min
Middleware and cross cutting concerns 5 lessons · 50 min
  • Video: How middleware works in Go 10 min
  • Video: Logging with slog and request IDs 11 min
  • Article: Recovering from panics 8 min
  • Video: Authentication middleware 12 min
  • Video: CORS and security headers 9 min
PostgreSQL with pgx and sqlc 4 lessons · 44 min
  • Video: Connecting with pgxpool 10 min
  • Video: Schema and migrations 10 min
  • Video: Type safe queries with sqlc 13 min
  • Video: Transactions and error mapping 11 min
Context, timeouts and background work 4 lessons · 42 min
  • Video: Context for cancellation and deadlines 11 min
  • Article: Server timeouts that matter 9 min
  • Video: A background reminder worker 12 min
  • Video: Calling external APIs reliably 10 min
Testing and shipping 6 lessons · 57 min
  • Video: Testing handlers with httptest 12 min
  • Video: Configuration and secrets 9 min
  • Video: Integration tests against PostgreSQL 11 min
  • Video: The race detector and benchmarks 9 min
  • Video: Graceful shutdown and a small container 11 min
  • Quiz: Final check 5 min

Requirements

  • Programming experience in another language
  • Basic Go syntax or willingness to learn it in section one
  • Go 1.22 or newer and Docker installed

Description

Go is a popular language for backend services. It compiles to a single binary, starts instantly, handles many concurrent connections well and has a standard library that covers most of what an API needs. Since Go 1.22, the built in router supports HTTP methods and path parameters, so many teams now build services with no web framework at all.

This course teaches you to build a production style JSON API with idiomatic Go. We build Lendr, a small service for tracking items lent to friends, with users, items, loans and reminders.

What you will learn

  • Go project structure, modules and packages for a service
  • Routing with net/http and the enhanced ServeMux patterns
  • Decoding, validating and encoding JSON
  • Middleware for logging, recovery, request IDs and authentication
  • PostgreSQL with pgx, transactions and type safe queries with sqlc
  • Using context for timeouts and cancellation
  • Structured logging with log/slog
  • Testing handlers and database code, and running with the race detector
  • Graceful shutdown, configuration and a small Docker image

Who it is for

You already program in another language, such as Python, JavaScript or Java, and you know the basics of Go syntax, or are willing to pick them up quickly with the short refresher in section one. You understand HTTP and SQL at a basic level.

The focus is on clarity: small functions, explicit errors and code your teammates can read. We avoid clever abstractions and keep dependencies to a minimum.

Who this course is for

  • Backend developers adding Go to their toolkit
  • Go learners who want to build a real service
  • Teams moving services from heavier frameworks to the standard library

Instructor

Leila Haddad

iOS and backend engineer teaching SwiftUI apps and the Go services behind them

  • 4.4 instructor rating
  • 14 reviews
  • 3,450 students
  • 2 courses
  • Sample

I work on both ends of mobile products: the iOS app in Swift and SwiftUI, and the backend services, which I usually write in Go. Seeing both sides has made me picky about clean APIs, clear error handling and code that a teammate can read a year later.

My courses are calm and structured. We start with the smallest working version, then add one concept at a time, with a short recap at the end of every section.

When I am not building, I contribute small fixes to open source Go libraries and help run a local meetup for mobile developers.

View profile

Student reviews

4.4 7 ratings
5 star 57%
4 star 29%
3 star 14%
2 star 0%
1 star 0%
Marcel E. Oct 3, 2026
Sample

Graceful shutdown done right

We had dropped requests during deploys. The shutdown lesson fixed it the same afternoon.

Andrea S. Sep 26, 2026
Sample

No framework needed after all

I did not realise how far the standard library had come. The new ServeMux patterns cover everything we needed.

Kenneth O. Sep 4, 2026
Sample

sqlc is a revelation

Writing plain SQL and getting typed Go functions is the best of both worlds. Great section.

Petra M. Aug 5, 2026
Sample

Clear and idiomatic

Leila's code is very readable. I wanted a bit more on authentication with external identity providers.

Ji-ho K. Jul 10, 2026
Sample

Context finally makes sense

The cancellation demo with a slow query made context click for me.

Farid R. Jun 11, 2026
Sample

Great testing section

Table driven tests with httptest are now how our team tests every handler.

Sienna L. May 4, 2026
Sample

Refresher is quick

If you are new to Go, the refresher lesson moves fast. I paused to do the Go tour first.

$59.99 Enroll now
SampleSample catalog: the instructors, courses, reviews and stats on this site are demo content.