6 Formatting, testing, debugging, and benchmarking
This chapter covers
- Creating well-formatted and readable code with updated dependencies
- Making resilient and structured logs for your application
- Creating unit tests and building strategies for designing test suites
- Analyzing your code’s performance and finding bottlenecks and problems
Go provides several tools out of the box that help keep your code clean, performant, and up to date. As you have experienced by now, the go
tool lets you build and run your packages, but it also provides some incredibly useful functionality that can help make working code rock-solid and production-ready. To get to this point, code typically should have good testing, both for performance and functionality (unit testing). We can use all of Go’s tooling to do this without the need for third-party software.
In this chapter, we’ll dig into linting our code, keeping imports up to date, following best-practice logging strategies, and testing and benchmarking our code. We’ll also look at features some common integrated development environments (IDEs) can provide to push us even further toward battle-tested apps and reduce errors in production.