32 ms·
There are two linters that add those checks: https://github.com/nishanths/exhaustive https://github.com/nishanths/exhaustive for values and https://github.com/a
by aleksi 2y ago
There are two linters that add those checks: https://github.com/nishanths/exhaustive https://github.com/nishanths/exhaustive for values and https://github.com/alecthomas/go-check-sumtype https://github.com/alecthomas/go-check-sumtype for types. Both are integrated into golangci-lint. I use both a lot and have only a positive experience.
Having support from the language would be nice, though.
- tialaramex 2y agoYeah, it makes a huge difference whether this is the default, and that's not a Go thing, it's not a programming language thing, it's the whole of human existence. Literacy is an example. We're used to a world where it's just normal that other humans can make marks and interpret our own marks as to meaning. A thousand years ago that would be uncommon, ten thousand years ago vanishingly rare. I really celebrate tools which take an idea that everybody agrees is a good idea, and bake it in so that everybody just has that, rather than agreeing it's a good idea but, eh, I have other things to do right now. And it annoys me when I see these good ideas but they're left as an option, quietly for a few people to say "Oh, that's good to see" and everybody else misses out, as if "Literacy" was an optional high school class most of your peers didn't take and now they can't fucking read or write. Example: Git has a force push feature, necessarily we can (if we have rights) overwrite a completely unrelated branch state, given any state X, now the state is our state Y instead. This isn't the default, that part is fine... Git also has "force-with-lease". This is a much better feature. Force-with-lease says "I know the current state of this branch is X, but I want to overwrite it anyway". If we're wrong, and X is not (any longer perhaps) the current state, the push fails. But force-with-lease isn't the default. [Edited to fix clumsy wording in the last sentence]
- dizzyVik 2y agoThese both look like great tools. I'll give them a spin!