Improved speed of the test harness
Improved speed of the test harness

Added a call to runtime.Gosched() before the call to server.Shutdown(). This drammatically improved the time it took to run the tests. It turns out that server.Shutdown polls every 0.5 s if all idle connections are closed. When we call server.Shutdown, our connection isn't closed just yet, so therefore we always have to wait 0.5 s for each test. But in reality it takes a lot less time than 0.5 s for the connection to finish closing. So if we just give up execution for a moment before calling server.Shutdown then the other goroutines have the time to shut the connection down before server.Shutdown checks if everything is closed. And then we don't get punished with waiting for 0.5 s every time we try to shut down.

With this approach sometimes tests still take 0.5 s to run. This might be because the scheduler continues execution on the same goroutine faster than the time it takes to close the connection. Putting in a time.Sleep(100 * time.Microsecond) instead of the runtime.Gosched() consistently makes the tests run faster, on my machine at least. But that is something I'll leave to be investigated at another time.

google/go-safeweb