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 when writing our applications. Each language uses different primitives and patterns that make the language unique, much like our own languages. We have words, ways to pronounce them, and ways to string them together into a standard 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 includes its own library, known simply as the standard library, as opposed to community libraries, which are installed afterward. We have already used some standard library functions and structures in 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 The fmt package

10.2 The flag package

10.3 The io package

10.4 The os package

10.5 The encoding package

10.5.1 JSON processing

10.5.2 XML processing

10.6 The bufio package

10.7 The regexp package

10.8 The strings package

10.9 The strconv package

10.10 Scratching the surface

Summary