When you have a large amount of developers working on a single project you can run into issues such as figuring out a particular developers code if they happen to have a different style compared to yours making it difficult to read through and understand. Because of these cases we utilize tools for formatting and linting code, in my case my project is written in Go and utilizes
goreturns for formatting and
golint for linting code. These tools use abstract syntax trees to represent the abstract structure of our source code to interpret our code and suggest changes.
golint are both packaged with golang by default and are pretty much considered the standard. Go especially has three separate formatters:
goreturns these formatters stem from
go fmt but have different levels of formatting.
go fmt is essentially the base golang formatter,
go fmt with import fixing (adding/removing imports that are used/unused) and finally
goimports with return statement syntactic sugar.
I had 4 issues with my code according to
goreturns which wanted me to document exported functions so all I had to do was add some comments.
I am already fairly familiar with go formatting as when you begin using it Google suggest installing their
golang.go extension for VScode as it automatically formats and lints your code making sure that even new users begin using these tools asap even without their knowledge. Luckily because Go has all these tools bundled with the language it makes my life easier for guiding contributors on setting up the environment as they don’t really have to install anything besides golang.
Thanks for reading!