Recent Posts
The dangers of struct embeding
Go comes with the ability to embed structs into other structs. It allows you to “reuse” fields and functions from one struct (the base) with another struct that embeds it. This can often be misunderstood as inheritance that you get from object orientated programming languages. While it can be useful and prevents having to duplicate code, it can also cause bugs that can be hidden in plain sight, which is what I encountered recently.
read more
Don't let ignore files get the better of you
Ignore files are great. They allow you to ignore (of course) files/directories in different scenarios. For example a .gitignore file can be used to prevent files from being committed to Git such as local secrets, built binaries or any temp files. Or a .dockerignore file can be used to only copy files into a Docker container that are actually needed for a build (there’s no point copying test code / resources if they aren’t needed).
read more
How the race flag caught me out
One of the many strengths of Go is its concurrency. But using concurrency comes with caution. Sometimes it’s not necessary and a lot of Go developers jump to using it too soon because they think it’ll solve a problem. I’m very guilty of having done that many times. However sometimes concurrency comes “for free” in the sense of http servers.
Let me explain that a little better. When you create an http server and run it, you can make 1000s of requests to that server and it will handle them concurrently, and you didn’t even have to do a thing, other than write ~10 lines of code.
read more