Posts for Go

Using GitLab's CI for Go Packages

Sat, Apr 25, 2020, ~1700 Words

Good support for continuous integration (CI) has become table stakes for online code hosting. Continuous testing and monitoring of your code can help raise and maintain code quality. However, even when you have access, configuring CI well takes effort. The goal of this post is to present a starting configuration suitable for Go projects hosted on GitLab. The configuration below should not necessarily be taken as complete. The project used here as an example is very, very simple, and so many complexities that larger projects face will be avoided, but it hopefully will serve as a good introduction.

Tags: programming, Go, CI

Read more →

Convenience Functions for Testing in Go

Wed, Sep 4, 2019, ~800 Words

Go’s excellent tooling extends to support for testing. Nevertheless, there are quite a few packages that exist to make it easier to write tests. In particular, Go’s verbose (although accepted) handling of errors is a weakness here, as writing tests can involve a lot of boilerplate. Compare writing a test case using, for example, Catch2, with what would be required if using solely the standard library in Go. Unfortunately, I have not found a utility package for testing that meet my design criteria.

Tags: programming, Go

Read more →

Design Comments on sync.WaitGroup

Wed, May 15, 2019, ~800 Words

The goal of this post is to look at the design of sync.WaitGroup. This type is obviously subject to Go’s compatibility guarantee, so it won’t be changing. Nevertheless, the curious might be interested in a comparison with an alternate design, and those ideas might be useful elsewhere. This comparison is by looking at sync.WaitGroup as one type of executor.

Tags: programming, Go

Read more →

Go's Code Coverage Resolution

Mon, Mar 25, 2019, ~1000 Words

For C++ development, I developed GCovHTML to generate reports on code coverage. For Go development, I use the builtin tool to generate these reports. The HTML reports generated by Go are nice in that that are a single file, but they do not include as much detail. To evaluate whether or not it would be feasible to process the profile data from Go using my tool, I investigated the format of the coverprofile output files. This turned up an interesting comparison in how Go tracks coverage data, and what that means for reporting.

Tags: programming, Go

Read more →

Go Should Have Assertions

Sun, Oct 21, 2018, ~700 Words

During the talk of proposals for new features for Go, such as simplifying error handling and generics, I found myself reaching for, and missing, a different tool. The proposals are not bad, but I use Go knowing that it is not an expressive language, and adjust accordingly. But working through a recent design, I found myself missing old-fashioned assertions. In particular, they can be used to document and enforce program invariants, such as preconditions or postconditions, in your code.

Tags: programming, Go

Read more →