Carl Johnson
blog.carlmjohnson.net · Personal blog · on HN since 2016
Carl Johnson is a Go programmer who writes about Go tooling, CLI design, web development, and programming history.
What HN saysHN commenters recommend his Go CLI architecture advice, praise his go:embed guide, and cite his argument against Gitflow.
23HN people shared it
7linked it in comments
33stories submitted
863story points
3 years agolast shared
2016people per year2026
Most-shared posts
- 1Writing Go CLIs with Just Enough Architecture · the Ethically-Trained Programmer5 people · 6 points · first shared 2020 · discussion on HN
- 2I wrote my own Go HTTP client3 people · 7 points · first shared 2021 · discussion on HN
- 3How to use go embed3 people · first shared 2021
- 4Three Minor Features in Go 1.182 people · 226 points · first shared 2021 · 90 comments on HN
- 5The 2,500 year old history of why Python’s all([]) returns True2 people · 191 points · first shared 2020 · 210 comments on HN
- 6Ten Years of “Go: The Good, the Bad, and the Meh2 people · 4 points · first shared 2023 · discussion on HN
- 7Dropping Support for IE11 Is Progressive Enhancement2 people · 4 points · first shared 2020 · discussion on HN
- 8The failed promise of Web Components2 people · 3 points · first shared 2020 · 3 comments on HN
- 9Never use a dependency that you could replace with an afternoon of programming1 people · 347 points · first shared 2020 · 328 comments on HN
- 10What’s New in Go 1.19?1 people · 53 points · first shared 2022 · 16 comments on HN
- 11Even More Minor Features in Go 1.181 people · 3 points · first shared 2022 · discussion on HN
- 12Major standard library changes in Go 1.201 people · 2 points · first shared 2023 · discussion on HN
- 13A Wizard Did It1 people · 2 points · first shared 2016 · discussion on HN
- 14Online Tracking Is Bad for Advertisers1 people · 2 points · first shared 2017 · discussion on HN
- 15Would you fund this grant proposal?1 people · 2 points · first shared 2021 · discussion on HN
What HN people wrote when they linked it
bokwoon · 2020-07-05
One of my favourite abstraction advice comes from this article: https://blog.carlmjohnson.net/post/2020/go-cli-how-to-and-advice.
"You want one layer to handle user input and get it into a normalized form. You want one layer to do your actual task. And you want one layer to handle formatting and output to the user. Those are the three layers you always need."
The "do the task" layer can be abstracted again further. But starting it off as a monolithic layer, separated from input and output, is always the right call.
earthboundkid · 2020-03-05
I recommended avoiding Gitflow back in 2018:
> There are more complicated systems for branching like Git flow that have a separate “develop” branch and distinguish between “features” and “hot fixes”. These systems are fine if they fit your use case, but if a project releases code quickly, the level of complexity involved in Git Flow is unnecessary.
> Ideally, branches should be short lived. One strategy to allow merging a branch before a large feature is fully completed is to create a feature flag that lets the production system have the new code in it but in an inactive state.
https://blog.carlmjohnson.net/post/2018/git-gud/
5e92cb50239222b · 2022-11-11
It's a bit more advanced than what Rust macros provided last time I checked. You can shove whole directories in there and then traverse them or serve as static resources with pretty much one line of code.
Random blog post with a few examples:
https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/
xaduha · 2021-10-27
Only tangentially related, but go:embed is pretty neat https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/
daoman · 2021-08-25
Yes, and it's super easy to do nowdays with embed since Go 1.16
https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/
coldtea · 2020-06-12
They use comments for compilation directives, build instructions, code generation and other such stuff.
https://dave.cheney.net/2018/01/08/gos-hidden-pragmas
https://dave.cheney.net/tag/build-constraints
https://blog.carlmjohnson.net/post/2016-11-27-how-to-use-go-generate/
kaushalmodi · 2018-06-12
I use this technique for cache busting with Hugo: https://blog.carlmjohnson.net/post/2017/hugo-asset-pipeline/. I am not a web developer, so have translated that flow to a simple Bash script which I run on Netlify.
Hugo v0.43 has inbuilt cache busting on the roadmap, and Hugo v0.42 will probably be released in about a week.