Luckily LLMs are quite good at these surgical changes. In fact I only used ~10% of my weekly limit on Codex (granted, I have the $100/mo plan) and a few iterations of review to implement them. I wouldn't go and use them in production in their current state but it's fascinating to see just how easy it is to add these features in a workable manner to projects as large as Go.
A little info on how each of the features work:
1. Tagged unions: These are compiled down to a struct with a series of 0-length arrays of each of the union field types. This enforces proper alignment. There is a byte array which is as long as the longest subfield where the payload lives. There is also an 8, 16, 32, or 64 bit variant field for distinguishing the active variant. Finally there is a "gc anchor" (codex's naming) which is a pointer to information for the gc to properly collect the active field. While this field is technically redundant, implementing unions without it would require a significant change to gc. Ideally I'd like to keep this fork (if I choose to maintain it) more or less in sync with master so I've decided not to do this for now.
2. Early return with "!": In a multi-value context if the final value is of type error I can use the special "!" bang operator. I can only use this operator if the current function I'm in has its final return type as an error. If both of these condition are met the bang operator will early-return from the surrounding function if the final value of the multi-value context is a non-nil error. This reduces a lot of "if err != nil" boilerplate.
Finally I asked the LLM to refactor the go source to use these two new constructs on this branch (https://github.com/jordan-bonecutter/go-plus-plus/pull/3). I haven't looked much at this branch myself but it easily (within about an hour) removed 5k+ lines of code from the go source. It also found some real bugs, like a potentially nil error value being returned in some plan9 code. Anyways, check it out and let me know what you think. Useful? Garbage? Thanks!