Chapter 2. Go quick-start

 

In this chapter

  • Reviewing a comprehensive Go program
  • Declaring types, variables, functions, and methods
  • Launching and synchronizing goroutines
  • Writing generic code using interfaces
  • Handling errors as normal program logic

Go has its own elegance and programming idioms that make the language productive and fun to code in. The language designers set out to create a language that would let them be productive without losing access to the lower-level programming constructs they needed. This balance is achieved through a minimized set of keywords, built-in functions, and syntax. Go also provides a comprehensive standard library. The standard library provides all the core packages programmers need to build real-world web- and network-based programs.

To see this in action, we’ll review a complete Go program that implements functionality that can be found in many Go programs being developed today. The program pulls different data feeds from the web and compares the content against a search term. The content that matches is then displayed in the terminal window. The program reads text files, makes web calls, and decodes both XML and JSON into struct type values, and it does all of this using Go concurrency to make things fast.

You can download and review the code in your favorite editor by navigating to the book repository for this chapter:

https://github.com/goinaction/code/tree/master/chapter2/sample

2.1. Program architecture

2.2. Main package

2.3. Search package

2.4. RSS matcher

2.5. Summary

sitemap