This PR does the following to codify our golang coding standards and keep us honest in this repo:
runs pre-commit in CI
enables a slew of golangci-lint linters (you can learn more here) I loosely populated out config based on this example there's plenty more we could enable and we can develop more sophisticated opinions over time.
I opted to silence some linter warning with a // nolint: xxx comment in the name of getting this already huge PR out the door. We can hopefully get around to removing as many of those as possible in the future.
High level explanation of changes
Making functions more readable: you'll see a lot of jake moving small bits of code into their own functions, the reason is the higher level orchestrating function becomes more easily readable because the smaller function names narrate what's going on, this makes it easier to get to the piece of code you're trying to change / debug.
functions should not be more than 50 statements (funlen)
functions should not be very complex (many nested if statement logics)
there's a lot of changes that have to do with no shadowing the name err this makes the code a lot easier to re-order / delete without having to figure out where err was defined
DRY up consts (e.g. massdriver ui)
follow Golang naming convention: all acronyms should be all caps not CamelCase (e.g. API not Api)
start to introduce the use of contexts. We can get more elaborate with this to be able to set timeouts, rate limits, or cancel requests when / if the cli gets more complex. It is generally considered best practice to "every time you make an API call there should be a context associated with that. I'm honestly not sure I defined contexts at the "proper level in the call stack" in this PR but at least we can start with this.
catch. every. error.
pretty format generated json
not a go change but i also pretty formatted all the json in this repo so we actually obey the end of file fixer in the pre-commit
make changes to dev container so the pre-commit / golangci-lint can run in the dev container (would be great if a reviewer could validate this on their machine)
This PR does the following to codify our golang coding standards and keep us honest in this repo:
golangci-lint
linters (you can learn more here) I loosely populated out config based on this example there's plenty more we could enable and we can develop more sophisticated opinions over time.// nolint: xxx
comment in the name of getting this already huge PR out the door. We can hopefully get around to removing as many of those as possible in the future.High level explanation of changes
err
this makes the code a lot easier to re-order / delete without having to figure out where err was definedconst
s (e.g. massdriver ui)