Go for Web Developers Workshop Part II
Meetup #55. Please RSVP at Meetup.
We get started at 6:30 pm.
Sponsors
Venue provided by Startup Edmonton.
Food sponsored by Bellstone Engineering.
Workshop
Part II of the Go for Web Developers workshop, taught by Chris Olsen, turned the weather library from Part I into a small web API. It covered configuring an app with flag (including defaults and -help), handling requests with http.Handler/http.HandlerFunc, and injecting a weather service through a handler struct. The workshop showed content negotiation using the Accept header to return either JSON (encoding/json) or rendered HTML (html/template), reading lat/lng query parameters, and pulling weather from the github.com/edmontongo/darksky service. It finished by refactoring away a global service variable in favour of interfaces and testing the API with a mock service and httptest.
Key points:
- Builds a web API on top of the Part I Dark Sky library.
- Configures the app with
flag(defaults, secrets,-help). - Uses
http.Handler/http.HandlerFuncand a handler struct to inject dependencies. - Negotiates JSON vs HTML via the
Acceptheader. - Serves
lat/lngquery parameters through the weather service. - Refactors the global service into an interface for testability.
- Tests handlers with a mocked API and
httptest.
Instructor: Chris Olsen
- Bring a laptop with Go installed.
- Slides from the workshop
News
- All About Go video with Francesc Campoy
- GothamGo videos
- Gopherpalooza videos
- LondonGophers videos
- The Past, Present, and Future of Go 2 slides by Dave Cheney
- GolangShow Episode 127
- compSci.Now() Episode 1
- Announcing App Engine’s New Go 1.11 Runtime
- Taking an indefinite sabbatical from my projects by Fatih Arslan (vim-go)
- Golang Weekly
Talks
- Hacktoberfest - Oct 22, 29
- GoLab in Florence, Italy - Oct 22-23
- Monthly Hack Day - Nov 3
- Edmonton Go Meetup - November