-
Forking Go Modules (Or Any Lib) Using Subtree
The two common patterns to forking a module are (1) forking via a separate repo or (2) vendoring, which forks all deps into the current module (or app). I recommend a third approach to forking using
git subtree
andgo mod edit -replace
. It’s very similar to repo forking without the repoLet’s say you’ve made modifications to
github.com/tj/go-spin
. Once preserving changes in a repo is needed, usegit subtree
to move the fork into your monorepo, or app repo -
Getting to Yes -- As Quickly as Possible
There was a great discussion a year ago about how fast gnu’s version of “yes” is. If you’re unfamiliar,
yes
outputsy
indefinitely.yes |head -5 y y y y y
The key takeaway was that
write
is expensive and writing page-aligned buffers is much faster. The is true across languages, so let’s see how to do it properly in go.If you’re shocked or impressed by the results, let’s see you do it in your language – post your results in the comments.