4 ms·
I’d like to get into go but in the past I’ve always been burned by not being able to quickly refactor my code. If I want to change the contract of get_kittens
by gorgoiler 4y ago
I’d like to get into go but in the past I’ve always been burned by not being able to quickly refactor my code.
If I want to change the contract of get_kittens so that it returns a set instead of a list, I found it quite tiresome to then go to all the call sites of get_kittens and change their types to match.
What was I doing wrong?* Perhaps there’s a cleverer tool out there that can infer and implement these type changes for me, automatically?
* using vim? [joke]
- taki_mekhalfa 4y agoThis is true for all typed languages though..
- Zababa 4y agoNo, type inference avoids this issue.
- yencabulator 4y agoWhich Go has. https://go.dev/ref/spec#Type_inference https://go.dev/ref/spec#Type_inference (Not to a level something like Typescript has it, but I'll argue that's a win. Typescript inferred typing can be hard to follow.)
- kstenerud 4y agoAlthough go has many deficiencies, this is not one of them. When you use "var" or "val", it works like "auto" does in C++.
- sudo_chmod777 4y agoI also use Vim. 1. Use `:=` whenever you can, so types are inferred by the assignments/allocations 2. Alternatively query all references from `gopls` and put the results into quick fix list, then `:cdo`