Ever need to just completely clear out an S3 bucket or a DynamoDB table using the AWS SDK? Think it will be one SDK call and then you’re done? Not so! The S3 console has an Empty button for each bucket and the AWS CLI has a aws s3 rm --recursive command. But the console doesn’t lend itself to automation and the CLI command doesn’t work for buckets with object versioning turned on.
Every decade or so, I become fascinated with sorting algorithms and spend some time implementing various approaches in my language of choice. The first time around, it was C++. Last time I took a stab at it, it was C#. This time around, I wanted to implement some popular sorting algorithms in Go. I think I enjoy it so much because sorting is easy to verify and there are so many varied approaches.
Go Modules is the official dependency management solution for the Go programming language. Recently, I finally converted over my personal projects. I had been putting it off for some time, since I was waiting for the Go team to finalize everything and work out all the kinks. Go 1.11 was when Modules was first released as a beta. Go 1.12 still had Modules in beta mode and Go 1.13 was when Modules came out of beta.
When I attended AWS re:Invent at the end of 2019, I attended a workshop for using machine learning via Amazon SageMaker to teach an AI how to play blackjack. Seeing as re:Invent was held in Vegas, I decided to take the spirit of Vegas home with me and create my own text-based blackjack game in Go. I added a simple interface so it would be easy to create different AI opponents.
This is waaaay overdue, but we had another hackathon at work back in September of last year and even though I’m waaaay behind on blog posts, I wanted to make sure I did a short writeup on my project. During Gophercon, I received a small Arduino Nano 33 IoT. Not exactly a powerhouse, but I wanted to do something with it. I bought a breadboard, sensors, wires, and other various components.
I recently spent some time figuring out how to gracefully shut down a Go service. The goal was to allow in-flight transactions to complete successfully before shutting down, but return Unavailable for any new requests. I found the solution to be fairly straightforward for Linux, but a little bit more tricky for Windows, specifically when running in a Windows Docker container. General solution for handling termination signals (Linux/Darwin) # For most use cases, the os/signal package works for capturing termination signals:
Another year and another Gophercon, this time in sunny San Diego! As usual, there were a lot of high quality talks across a breadth of subjects. I highly recommend browsing through the Gophercon videos on YouTube, but I’ll highlight what I thought were the interesting bits below. The last year or so has seen a LOT of discussion around dependency management for Go, particularly around dep and Go Modules (formerly vgo).
When the theme for our latest company hackathon was revealed to be “Need for Speed”, I went straight to Best Buy after work and picked up a DJI Tello drone. I had been wanting one ever since I went to Gophercon and saw the presentation by Ron Evans where he used Gobot and GoCV to make a Tello drone follow his friend’s face around. Now that I had a drone, I needed to figure out what to do with it.
Something that Go does very well is multi-platform support. You can build a binary for just about any system without much hassle. On a single build machine, you can build binaries for Windows, macOS, and many flavors of Linux. All that is required is to change the GOOS and GOARCH env variables to the desired OS and architecture. I made a Makefile to take advantage of this. First I started with a few variables.
Recently, I had the need to process a near infinite number of messages asynchronously. You can’t just throw all the messages into separate goroutines when there are that many of them and more incoming. One solution is to use some sort of worker pool to manage the number of concurrent goroutines that can run. Here’s how I went about creating a worker pool (I’ve called it a task pool) in Go.
I had the privilege again this year to fly out to Denver and attend Gophercon, the premier gathering of “gophers” (people who program in Go). It’s a lot of fun and I learn something every time. After spending the weekend hanging out around town with my wife, enjoying Hammond’s candy and exploring the Denver Museum of Nature and Science, I started the conference with a machine learning workshop. It turned out to not be quite what I expected.
A couple weeks ago, we had another hackathon at work. This time, I wanted to create something useful that could potentially be adapted by one of our teams. My initial thought was to convert some of our old C++ code to Go and remove a Windows dependency, but after talking with one of my coworkers, we decided to instead create a DNN service for executing a Caffe2 model in Go. We had a third volunteer join us and we set out to achieve our goal.