Filed Under #golang
Goodreads is one of my favorite services, as I love reading (and spend quite a bit of time doing it, to be honest). My goal for 2019 is to read 75 books, and an additional 3 books in German as I’ve been learning the language over the last couple of years. Here’s where I’m at so far, and we’re only in January:
I thoroughly enjoy writing and generally when I write, I do so using Markdown for formatting. Markdown is great because it can be easily exported to HTML, a PDF, Word Documents, etc. There's great tooling around Markdown, abd it's a well supported markup language. My only problem is when I'm writing larger documents, such as if you were to write book, you quickly end up with a massive, unwieldly document. That's where modoc comes in!
In Parts 1 and 2 of the OpenGL with Go Tutorial we learned how to draw shapes and created a grid that will act as our game board. Now it's time to implement Conway's Game of Life and see some simulations!
In Part 2 of the OpenGL with Go Tutorial we pick up with the triangle we left off with, and make a square out of two triangles. Then, we make an entire grid of squares to act as our game board.
OpenGL is pretty much the gold standard for any kind of graphics work, from desktop GUIs to games to mobile applications and even the web, I can almost guarantee you’ve viewed something rendered by OpenGL today. However, regardless of how popular and useful OpenGL is, it can be quite intimidating to get started compared to more high-level graphics libraries. The purpose of this tutorial is to give you a starting point and basic understanding of OpenGL, and how to utilize it with Go. There are bindings for OpenGL in just about every language and Go is no exception with the go-gl packages, a full suite of generated OpenGL bindings for various OpenGL versions.
Named profiles are a great way to simplify working with multiple AWS accounts and profiles, but it can be a little tedious when it comes to using SDKs and third-party applications that don't provide support for them. awsprof aims to alleviate some of that pain.
Nobody likes a big dependency tree, particularly on external third-party packages that need to be maintained, debugged, vendored, etc. While working on Commuter I was experimenting with the new dependency management tool, ‘dep’ and began to wonder exactly how many packages I’m pulling in and how they’re being used.
Commuter is a handy little application I wrote that uses the Google Maps API to calculate the travel time between two locations given current conditions. Where I find it particularly useful, however, is in adding aliases for frequent locations throughout the city, so I can see how long my drive home or to the gym is without leaving my terminal.
docker stats is a useful command to get an overview of the resource usage of your running Docker containers. For instance, you can see the current memory, CPU, and network usage of your containers.
Recently while writing test cases for s3fs I came upon a situation where a function returns an interface, however the underlying type of the interface is dependant on the input. What I wanted to do was validate that the appropriate type was being returned for each supported input scenario.
Converting the results of a SQL query to a struct in go is trivial, but sometimes you don't know ahead of time exactly what columns and types you're going to be retrieving, and a map is better suited for storing the results.
Maintaining locks across a cluster of application instances, be it multiple threads on the same server, or different servers altogether, is an often underestimated piece of developing clustered applications. It's relatively straightforward but there are some gotchas to look out for when implementing your distributed locking mechanisms.
Defer is a powerful control flow mechanism that is unique to Go (at least until Swift 2.0 added it). It allows you to defer a function call to the end of the currently executing function no matter how or where it returns. This is useful for many reasons, the most common of which are to close an open connection or unlock a Mutex immediately before the function ends.
Alpine Linux is a popular Linux distribution that is incredibly light-weight: approximately 5MB only. Deploying with Alpine is beneficial because downloading the Docker image is extremely fast, and you have no extra overhead from running services in your container that you don't need. Luckily the official golang Docker image has an Alpine variant that we can use, so adapting Alpine for our needs is going to be straightforward.
The Mutex (mutual exclusion lock) is an invaluable resource when synchronizing state across multiple goroutines, but I find that it's usage is somewhat mystifying to new Go developers. The truth is that mutexes are incredibly simple to use, but do come with a couple caveats that can have a serious impact on your software - namely deadlocks.
So you've written a Go application and you're ready to distribute it to your users, but how do you support platforms other than the one you develop on? Sure you could go out and buy a machine or lease a server of the target type, compile your application on there, and take the binary - but who wants to do all that? Not only is that costly, inefficient, tough to automate, but it's just an overall nightmare. Well luckily the solution is no-where near as complicated as that, as Go comes with cross-compilation support built in since version 1.5.
I've added Go as one of the supported languages in my XOREncryption repository, and I'd like to show just how easy it is to use.
Slices in Go are quite nice to work worth, but the standard library doesn't provide any way of creating a unique slice. Since this is such a common requirement, the community has come up with a few tricks to accomplish this, and I figured I'd share the one that is the most common, and perhaps simplest to write.
Like most languages, Go values small, reusable, self contained packages and functions that can be easily reused, tested, and modified. In order to accommodate this, I find the best thing to do is to create your own go-kit, a collection of small packages that each have a very specific purpose.