respecting the conventions & norms of the repo I am contributing to
passing most linters: like all error results should be checked, unused public fields should be private, etc
How can I train to improve my code quality ? Any suggestions ? It is a skill like any other, but so far I could not come up with a way to train this skill specifically.
That’s a good and important question, and I think there is no easy answer, but here are some thoughts.
Respecting language idioms and project conventions requires that you have all those idioms and conventions at hand. Yes, that means learning them by heart, but this does not need to happen all at once.
Passing linter checks can be achieved by, well, running linters on your code and adjusting the code as required. This is a technical problem with a technical solution. No one expects that your code is perfect on the very first linter run.
The remaining two bullet points, SOLID and high-quality code, are certainly the toughest ones. I guess you cannot take shortcuts here but have to
read a lot of other people’s code, ideally that others already have reviewed and tagged as high- or low-quality (and provided reasons for their judgement).
write a lot of code and have it reviewed by experienced devs. Don’t be embarrassed by bad code that you wrote, you can always refactor it.
learn to write good tests. Quality is measured in numbers of bugs and robustness in the face of rare edge cases, so if you know how to test your code well, you know how to maintain quality.
There are many ways you can improve your coding skills:
Get some practice by working through the exercises. The exercises are designed to help you develop a range of skills, so if you’re stuck on one exercise it might be worth doing another one first.
Read lots of code! You’ll find that by reading and writing lots of code, you’ll learn more than from any one tutorial or book.
Study other people’s code! There are many websites that let you see how professional developers write their code.
Can you post a link to these exercises ? I think some katas, or refactoring problems, that have the option to check your solution against an ideal one, would be awesome.
These coding websites are nice, but they help mostly with algorithms, not with code quality directly. Do you have any advice on how to use them, in order to improve code quality ?
I will be as practical as possible and give you some ideas that you can accomplish in the short term of period if you are practical and curious to know more!
high quality code, which passes any code review
it takes time to master things even though learning Go is dead simple. It is OK to take time and read everyone else’s code and practice on your own. Keep in mind, I am not suggesting leetcoding or fast paced competitive programming to improve on this. It is purely based on reading more and writing more and getting more feedback.
passing most linters: like all error results should be checked, unused public fields should be private, etc
I can suggest golangci-linter for this and I highly suggest for you to come up with your own configuration. For example, this is my configuration for the set of linters I use; https://gist.github.com/MrWormHole/250a8a1f78ca17c059b8ce075bbc28ec