10 The standard library

This chapter covers

  • Providing a correct time duration
  • Understanding potential memory leaks while using time.After
  • Avoiding common mistakes in JSON handling and SQL
  • Closing transient resources
  • Remembering the return statement in HTTP handlers
  • Why production-grade applications shouldn’t use default HTTP clients and servers

The Go standard library is a set of core packages that enhance and extend the language. For example, Go developers can write HTTP clients or servers, handle JSON data, or interact with SQL databases. All of these features are provided by the standard library. However, it can be easy to misuse the standard library, or we may have a limited understanding of its behavior, which can lead to bugs and writing ...

Get 100 Go Mistakes and How to Avoid Them now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.