› Dan Peterson

Hi, I’m Dan. Usually danp.
Testing code that involves time or concurrency can be a struggle. It often leads to hard-to-debug flakes in CI or long-running tests. Go 1.24 is scheduled to be released in February and the release freeze has begun. It’s set to include an experimental testing/synctest package designed to make testing code that involves time or concurrency precise and fast. I’m pretty excited about it! Time testing trouble Suppose you have a test that looks like this:
Nov 18, 2024
I’ve been having a lot of call trouble at home lately using Eastlink and an iPhone 13 mini. Even though I have all the signal bars: Full bars Received and placed calls would fail right away or audio would cut in and out for both sides. I’ve been working with Eastlink support but no breakthroughs yet. Today, I got to thinking there must be a way to see more detailed signal/noise info.
Where possible, I like to build systems around convergence. These systems generally look something like: Tick on some regular interval (10 minutes, 1 hour, etc) Update the view of the world (discover new data, observe a value, etc) Act on the updated view, possibly comparing to the previous view (stop some servers, process newly discovered data, etc) For example, an auto scaling group would continually check instance health, load, etc, and converge on the desired or optimal number of servers by starting new ones or stopping existing ones.
Nov 13, 2022
It seems like Twitter may not be around much longer. Even if does stay around, it’s not likely to be a place I want to be anymore. Like many folks, I decided to dip into the Fediverse. Using Mastodon seemed like a good first step. I set up an account on mastodon.social but quickly realized it was overwhelmed. There were other servers to join but I wanted to run my own.
Summary Starting in Go 1.201, DNS lookups when running on macOS will be done via the system instead of via Go’s built-in resolver. That’s even when cgo is not available, such as when cross-compiling from Linux. That should reduce surprises for people using tools cross-compiled for macOS from Linux, such as CLIs like terraform and kubectl. It should also make it easier for developers of those tools as building on macOS may no longer be necessary.
Halifax has a systemic road safety problem. One way it manifests is people driving too fast, especially on residential streets. Recently, Halifax Regional Council mostly approved their 2021 capital budget. It includes $1 million for traffic calming and the final budget may include $1 million more. Read more about that here or here. The city publishes a ranked list of approved requests. Not all requests are approved due to rules that contribute to the systemic problem.
As part of Heroku Private Spaces we attach extra Elastic Network Interfaces to instances, and we do that in Go with aws-sdk-go. The process isn’t the most idempotent and we recently discovered we were occasionally leaking ENIs. This could happen if we created an ENI and then encountered an error later in the process, such as when attaching it to an instance. I set out this morning to find a better way.
One of my favorite localized Go refactorings is reducing nesting by using return as early as possible. Take this example, based on a recently-refactored function at Heroku: func example() error { if err := start(); err != nil { existing, err := fetchExisting() if err != nil { return err } if existing.IsWorking() { return nil } else { return errors.New("found existing but it's not working") } } return nil } This can be hard to follow due to nesting inside if .
At Heroku we use Travis CI to run project tests on push to GitHub. While Travis CI offers PostgreSQL in their environment, it’s version 9.1. A project I’m working on recently started using PostgreSQL 9.2’s JSON data type, which 9.1 does not have. Needing 9.2, I searched for ways to make it available in the Travis CI environment. I found guides that suggested upgrading PostgreSQL in a before_script but I didn’t have much luck with that approach.
Since July 30th, I’ve been using ledger (on GitHub) to track my personal finances. What did I use before? I’m ashamed to say nothing beyond my banks’ sites. I stumbled upon ledger via this blog post, linked from Hacker News. It took me a while to try it, for a few reasons. First, I had a weird notion that there would be a better time in my various “fiscal cycles” to start using such a thing.
« Older posts Newer posts »