chapter ten

10 The Standard Library

 

This chapter covers

  • Command line tool creation basics
  • Discovering libraries within the standard library
  • Using the standard library for common use cases

Programming languages provide us with a basic syntax and grammar to use to write our applications. These are achieved through primitives and patterns that make the language unique, much like our own languages. We have words, ways to pronouce them, ways to string them together into a common grammar and we compile them into pages, books, and libraries. With programming languages we end up making our own types of libraries or collections of commonly used code that speed up development.

When Go is installed, it is shipped with its own library known simply as the standard library as opposed to community libraries which are installed afterwards. We have already used some standard library functions and structures in some of our small programs. In fact, it is fairly difficult to write anything without a standard library. The fact that so much can be done with the standard library makes Go a great language for modern application development.

10.1 fmt Package

10.2 flag Package

10.3 io Package

10.4 os Package

10.5 encoding Packages

10.5.1 JSON Processing

10.5.2 XML Processing

10.6 bufio Package

10.7 regexp Package

10.8 strings Package

10.9 strconv Package

10.9.1 Converting Numbers to Strings

10.10 Summary