Learn Go the Practical Way

Build real backend services with hands-on exercises. Learn the skills companies actually use.

Start Learning Free

Join 2,500+ developers learning Go

server.go
Lesson 18 — HTTP Servers

Build a REST API

Go's net/http package makes building web servers simple. No frameworks needed.

Your task:

Create a health check endpoint that returns JSON status.

+30 XP for completing this lesson
package main
import "net/http"
func healthHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"status":"ok"}`))
}
func main() {
http.HandleFunc("/health", healthHandler)
http.ListenAndServe(":8080", nil)
}
Output Passed
$ curl localhost:8080/health
{"status":"ok"}
✓ Health check passed · 200 OK

Everything you need to become a Go expert

40+ courses covering fundamentals to production-ready skills. Learn by doing with hundreds of hands-on exercises.

1

Go Fundamentals

Variables, types, functions, pointers, interfaces, and generics. Build a rock-solid foundation.

8 courses
2

Concurrency

Goroutines, channels, mutexes, and worker pools. Write fast, parallel programs.

12 lessons
3

Standard Library

HTTP servers, JSON, file I/O, testing, logging with slog, and CLI tools.

8 courses
4

Databases

From raw SQL to GORM ORM. Migrations, relationships, and transactions.

2 courses
5

Clean Code

Idiomatic patterns, error handling, interface design, and code organization.

5 courses
6

Docker & Kubernetes

Containerize apps, write Dockerfiles, and deploy to Kubernetes.

4 courses
7

Microservices

Service architecture, gRPC, protocol buffers, and distributed systems.

3 courses
8

Projects

Build a URL shortener, task queue, cache, and log aggregator from scratch.

4 projects

Learn Go the way that works

GoLearn is built around one idea: you learn to code by coding. No setup. No environment headaches. Just you, the lesson, and your code.

Solve real-world challenges

Hands-on exercises with instant feedback. See your code run and get immediate results.

Exercise HTTP Servers
Add a JSON Health Endpoint
Your Task

Add a /health endpoint that returns JSON with status and timestamp.

Requirements
  • Returns HTTP 200 status
  • Content-Type is application/json
  • Response includes "status": "ok"
  • Response includes timestamp field

Write production-ready code

Learn the patterns and practices that companies actually ship to production. No toy examples.

health.go
func handleHealth(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]any{
"status": "ok",
"timestamp": time.Now().Unix(),
})
}

Earn achievements

Track your progress with achievements for streaks, milestones, and mastery.

Go Master Legendary

Complete all courses

First Steps Rare

Complete your first exercise

Week Warrior Epic
5/7
Start Learning Free

Simple pricing

Start free. Upgrade when you're ready.

Free
$0 /forever
  • First 20 lessons
  • In-browser code editor
  • Progress tracking
  • XP and streaks
Get Started

Common questions

No. Everything runs in your browser. You write code, hit run, and see results. No Go installation, no IDE setup, no config files.
Complete beginners are welcome. We start from "what is a variable" and build up. If you know another language, you'll move faster, but it's not required.
Most learners finish the basics in 2-3 weeks with 30 minutes a day. The full curriculum takes about 2 months at that pace. But you learn at your own speed.
Yes, anytime. No questions asked. You keep access until the end of your billing period. Your progress is saved forever.
Yes! The first 20 lessons are completely free. No credit card needed. And Pro comes with a 7-day free trial if you want to explore everything.
Every lesson has hints if you need them. You can also reset your code to the starter template. And our community Discord is there if you want to ask questions.

Start writing Go code today

Join thousands of developers who learned Go the hands-on way. Your first lesson is 60 seconds away.

Start Learning Free

No credit card required