Testing API Clients in Go

Let’s imagine you are building an API client in Go to make it easier for people to interact with your public REST API. Everything is going great. You’ve got authentication, pagination and awesome error handling in place. One thing that’s still unresolved though is how do you test it? Your client exists to make HTTP requests and then unmarshal that response data (presumably JSON) into objects that make it easy for your consumers to work with. »

Option Types with go generate

This post is about a library and command I created called optional with the help of go generate. The code is here: https://github.com/markphelps/optional if you want to follow along. I’ve been coding in Go for some time now, and one thing I miss from my Java days is the ability to express an option type. An option type (from the Java docs) is: A container object which may or may not contain a non-null value. »

Functions as State

Recently I’ve been working on a Slack bot project in Go using the wonderful nlopes/slack client. While nlopes makes it easy to post and consume messages to and from Slack, either via the Web API or Real Time API, I found myself struggling when trying to maintain conversation state between users and the bot. Any good Slack bot is able to listen to and respond to messages given some cue or trigger. »

Writing a Ray Tracer in Go - Part 5

This is the 5th and final post of my series on writing a ray/path tracer in Go. Check out the previous parts 1, 2, 3 and 4. I’m roughly following the e-book Ray Tracing in One Weekend, but translating all of the code into Go. All of the code for this post can be found on my Github. Last time we added metal and matte materials, giving us the ability to render the following image: »

Writing a Ray Tracer in Go - Part 4

This is part 4 of my series on writing a ray/path tracer in Go. Check out parts 1, 2 and 3. I’m roughly following the e-book Ray Tracing in One Weekend, but translating all of the code into Go. All of the code for this post can be found on my Github. Last time we added the ability to shade our sphere and added anti-aliasing to make everything look better. »