nomad
nomad copied to clipboard
tools: structs method generation
Developers are required to implement methods like Copy, Equals, Diff,
and Merge for many of the types in the structs package, and this is both
time-consuming and error prone, having resulted in several correctness bugs
from failing to copy objects retrieved from go-memdb or failing to compare
objects during plans.
This changeset introduces a prototype tool to use with go:generate
directives that can generate methods automatically for our developers. Future
changesets will include documentation for developers and porting the existing
methods to use this tool. We'll continue to debug and refine the tool as we
go.
(Co-authored with @DerekStrickland )
@schmichael @tgross I'll take a stab at a README, similar to what I am doing in this jobspec update PR https://github.com/hashicorp/nomad/pull/10819.
Also, I had some readability/maintainability refactorings in another branch that didn't land in time for Friday. I'll take a stab at rebasing it off of this + adding comments and then see if we want to merge.
@tgross @schmichael Here's the other branch. Let me know if you'd prefer a PR targeting this one. https://github.com/hashicorp/nomad/tree/generate-structs-refactor
Let me know if you'd prefer a PR targeting this one.
You can probably just drop commits onto this PR if you want, but I'd strongly recommend splitting the file rename refactor from any other refactors so that folks can review them separately. Ex. right now https://github.com/hashicorp/nomad/compare/generate-structs...generate-structs-refactor just show the whole file getting replaced.