HN user

gus_leonel

1,581 karma
Posts222
Comments12
View on HN
bitfieldconsulting.com 7mo ago

When doomed stubs attack: blockchain voting and proof of work

gus_leonel
1pts0
blog.jetbrains.com 9mo ago

The "10x" Commandments of Highly Effective Go

gus_leonel
3pts0
gopodcast.dev 10mo ago

Is Go Over? [audio]

gus_leonel
1pts0
bitfieldconsulting.com 11mo ago

Goroutines: A Gentle Introduction

gus_leonel
2pts0
bitfieldconsulting.com 11mo ago

Here comes the sun: a fast weather client in Rust

gus_leonel
2pts0
ashouri.xyz 11mo ago

Waiting for King Sebastian

gus_leonel
1pts0
bitfieldconsulting.com 1y ago

Go generics doesn't work with struct fields

gus_leonel
3pts0
bitfieldconsulting.com 1y ago

Let There Be Bobcoin

gus_leonel
2pts0
ashouri.xyz 1y ago

Are We Scribes?

gus_leonel
1pts0
bitfieldconsulting.com 1y ago

When to choose Rust, and when to choose Go

gus_leonel
3pts0
redixhumayun.github.io 1y ago

Cache Conscious Hash Maps

gus_leonel
3pts0
bitfieldconsulting.com 1y ago

Are You Master of Your Domain?

gus_leonel
2pts0
tip.golang.org 1y ago

A Guide to the Go Garbage Collector

gus_leonel
1pts0
bitfieldconsulting.com 1y ago

Writing Terrible Code

gus_leonel
1pts0
go.dev 1y ago

Effective Go

gus_leonel
2pts1
bitfieldconsulting.com 1y ago

Seven Rust books that don't suck

gus_leonel
3pts0
jarosz.dev 1y ago

Don't Overload Your Brain

gus_leonel
2pts0
bitfieldconsulting.com 1y ago

Go vs. Python

gus_leonel
2pts0
billydm.github.io 1y ago

Rust vs. C++

gus_leonel
4pts0
bitfieldconsulting.com 1y ago

Rust and Go vs. Everything Else

gus_leonel
3pts0
ashouri.xyz 1y ago

Ehsan Ashouri

gus_leonel
1pts0
bitfieldconsulting.com 1y ago

Go's map[string]any type

gus_leonel
3pts1
corrode.dev 1y ago

Thinking in Expressions

gus_leonel
2pts0
bitfieldconsulting.com 1y ago

Go's best-kept secret: executable examples

gus_leonel
2pts1
www.bbc.co.uk 1y ago

ZX81: Small black box of computing desire

gus_leonel
3pts0
bitfieldconsulting.com 1y ago

Rust vs. Go in 2025

gus_leonel
8pts0
stackoverflow.blog 1y ago

Supporting the most-used database engine through 2050

gus_leonel
2pts0
bitfieldconsulting.com 1y ago

Rust and Go vs. Everything Else?

gus_leonel
3pts0
archive.fosdem.org 1y ago

Testing Go programs with testscript [pdf]

gus_leonel
1pts1
bitfieldconsulting.com 1y ago

Go Has Iterators

gus_leonel
1pts0
A Crack in the Cosmos 11 months ago

I'll never see an earth-rise

You wouldn't see one even if you were on the Moon, which doesn't rotate with respect to the Earth. (In the spirit of your comment, you can satisfy yourself about this intuitively by reflecting that we always see the same face of the Moon, so somebody on that face wouldn't see the Earth changing position in the sky, either.)

This:

Error handling is the most important part of any program. Anyone can write the happy path! It’s what the program does when something weird, unexpected, or awkward happens that really distinguishes well-engineered software from janky hacks.

“If you get fired as a result of applying the advice in this book, then that’s probably for the best, all things considered. But if it happens, I’ll make it my personal mission to get you a job with a better company: one where people are rewarded, not punished, for producing software that actually works.”

I came up with this idea because I was trying to encourage people to think about how they name their tests. One useful technique is to make the test name a complete (but brief) sentence describing the required behaviour.

This is helpful when the test fails, because you see the name printed out as part of the failure message. But it's also a good thinking tool as you're writing the test, because you have to start by deciding exactly what the behaviour under test should be.

As some guy named Sam Altman said, "If it takes more than a sentence to explain what you're doing, that's almost always a sign that it's too complicated." This is a good guide for programmers too, because the amount of behaviour that can be concisely described in a sentence is also about the right amount for a software component or function.

Hence a program that parses your (Go) test names, eliminating camel case and underscores and so forth, and prints them out as readable English sentences. For example, if the test name is 'TestFooReturnsErrorForInvalidInput', the program will print:

  Foo returns error for invalid input
(preceded by a tick or a cross to show the current test status)

To try it out, run:

  go install github.com/bitfield/gotestdox/cmd/gotestdox@latest
Then run 'gotestdox' in some Go project or package (the default target is the current package, but it can also take any arguments that 'go test' takes, such as a package list like './...').

The original implementation of this simple but useful idea was 'agiledox', written by Chris Stevenson for JUnit. It has been ported to various other languages and test frameworks, but not (as far as I know) to Go, until now.

I wrote an article explaining in more depth why I think test names should be written as sentences, and how 'gotestdox' can help with that: https://bitfieldconsulting.com/golang/test-names