Go Learn - Write a HTTP API

2019-03-13
by

Learn the basics of constructing a HTTP API with focus on logging and error handling from the very start. We'll start from hello world and evolve into a more advanced API.

Each step is represented as a diff, so you can follow along with the changes. But the contents of the entire file is always available for each change. I recommend you to type in those changes manually, copy-paste never taught nobody nothin. I've provided tests for all changes but you'll have to explore those on your own. Also each change comes with a components diagram showing the overall design.
If the comments are somewhat sparse it's because this material was used in a course where I explained each concept in more detail. Please let me know which part might benefit from more discussion/explanation.

This tutorial was prepared with Go 1.12 as a module with the following commands

mkdir -p $HOME/tutorial/cmd/app
	touch $HOME/tutorial/cmd/app/main.go
	cd $HOME/tutorial
	go mod init tutorial
      
When you follow along run the tests and compile using
cd $HOME/tutorial
	go test ./...
      

Table of contents

    next