This is nice because I can use any `io.Writer` as the `stdout`. In my tests, I use bytes.Buffer - which allows me to capture (and make assertions about) what the tool outputs.
I can also play around with any flags or arguments without having to do anything weird :)
3/6
You can pass in anything that you might otherwise go straight to the os package for.
os.Args, os.Stdin, os.Stdout, os.Stderr
You can even use a `func(string) string` to stand in for os.Getenv - then you can control the env vars in test code.
4/6
Returning an error from run is also a nice benefit. Since you cannot return error from `main` functions in Go, you can be left writing error handling code multiple times.
With our run abstraction, we just have to handle the returned error once.
5/6
So `main` ends up being untested, but since it's just calling `run` and passing in things from the os package, we can trust ourselves to get that right.
It's time to get rid of estimates in software engineering. They don't work, do more harm than good, and drive people to act in dishonest ways.
Buckle up people, it's a thread.
"How long is this going to take?" feels like a completely reasonable question, but how come "I don't know" isn't a
reasonable answer?
"We just need a ballpark figure, you won't be held to it," they lie.
Well how come we just had to work the weekend?
Estimates are an effort to try and predict _when_ something is going to be ready. This is necessary so the rest of the business (sales, other dev teams, cult leaders, etc.) can line up and coordinate their efforts.
This is the best PR I've ever opened. Someone has a PDF of my book in their GitHub repo.
UPDATE: the PR got merged 😂🥳
To celebrate I am going to BUY five copies of my own book (Go Programming Blueprints: Second Edition) for anyone who wants, it but can’t get it themselves.
Reply if interested and I’ll abuse a Go map to randomly pick five winners.