Authenticate Cloud Vision Client in Go

Google’s Cloud Platform documentation is top of the line. Even with the documentation though, it took me some time to figure out how to use the Cloud Vision API from a Go application running on a Compute Engine instance. All the right information is there, but it’s scattered. Below I’ve compiled this information into a few steps. Authenticating with the Cloud Vision API involves more setup than the Cloud Datastore, Cloud Pub/Sub and Cloud Storage....

May 28, 2017

User Email Addresses with Go-GitHub

I’ve been working on a new web app lately and decided to allow users to sign up and log in with their GitHub account. I’m using go-github to interact with the GitHub API and with this library there are two different ways to get a user’s email address. If you want to get the current user’s primary email address, use the Users.ListEmails() method. This method returns all the emails associated with the GitHub user and indicates whether the email address is their Primary address....

June 8, 2015

Go-YAML Field Names

I wasted away a good thirty minutes trying to figure out why I couldn’t parse my YAML config file this morning using go-yaml. package main import ( "fmt" "log" "gopkg.in/yaml.v2" ) var configText = ` Message: Welcome UpdateInterval: 5 EmailAddresses: - john.doe@example.com - jane.doe@example.com` type Config struct { Message string UpdateInterval int EmailAddresses []string } func main() { var c Config if err := yaml.Unmarshal([]byte(configText), &c); err != nil { log....

February 14, 2015