Made with Drew

Go enthusiast

Go benchmark md5 sha1 sha256

I needed to add checksums for caching url resources. The internet was surprisingly vacant of good benchmarks of different hashing methods. It’s very easy to do these kinds of tests in Go, so here’s one. Go has a well crafted hash package. Then to use a specific hashing function, simply implement this interface with one of the many available crypto functions. For this test, I only tested md5, sha1, sha256, and the 32bit hash crc32.

Division by Zero

Found some interesting idiosyncrasies while doing some floating point math. float64(1) / 0 // panic: division by zero float64(1) / float64(0) // panic: division by zero All good so far, then it gets more interesting. var f1 float64 f1 = float64(0) float64(1) / f1 // +Inf float64(0) / f1 // NaN It appears the compiler provides some safety when using static types, but does not provide the same benefit for variables.