Miki Tebeka [email protected]
In this hands-on workshop about getting started with the Go programming language. Learning will be done by writing some REST APIs. This class is for people who would like to get started with Go and have some experience in programming.
- In Setup we'll make sure you have all that is needed to complete the workshop
- We'll start by writing the customary "Hello World" program
- Program structure, import path, types
- Now we can add some tests
- Testing, declarations,
if
statement
- Testing, declarations,
- Next we'll add ping & time handlers
- HTTP protocol, REST overview
- After that we'll set and get keys
- map, slicing, byte arrays, defer
- Then we'll return all the keys
- slices,
for
loop, empty interface, JSON
- slices,
- We'll use gorilla/mux to simplify routing
go get
- Finally we'll support concurrency
- goroutines, locks, struct
The best way to learn a programming language is to find a problem and solve it using the language. If the problem is something that "itches" you - even better.
Here are some ideas on how to improve our web server:
- Add a command line argument for the port to listen on
- Support multiple databases
- Instead of using a
sync.Mutex
to guard our data structure. Use a goroutine that will listen on a channel for commands and return result over a channel - Implement more commands, see redis commands for inspiration
- Test everything
- Including running the server and calling it over HTTP
- ...
List of examples used in the lessons:
- cond.go - Conditionals
- defer.go - defer
- empty-iface.go - The empty interface
- for.go - For loops
- goroutines.go - goroutines
- json.go - JSON encoding
- maps.go - maps
- mux.go - gorilla/mux
- slices.go - Slices
- struct.go - Structs
- vars.go - Variable declaration
- Go main site
- Package Documentation
- External Packages Documentation
- Effective go
- How to Write Go Code
- A Tour of Go
- When Googling - use the term
golang