Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 2.1 KB

readme.md

File metadata and controls

25 lines (18 loc) · 2.1 KB

Feed Search Application

To see Go in action we are going to build a complete Go program. The program 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 to the terminal window. The program reads text files, makes web calls, decodes both XML and JSON into struct type values and finally does all of this using Go concurrency to make things fast.

Program Architecture

The flow of the programs architecture.

The program is broken into several distinct steps that run across many different goroutines. We will explore the code as it flows from the main goroutine into the searching and tracking goroutines and then back to the main goroutine. To start, let's review the structure of the project:

cd $GOPATH/src/github.com/ArdanStudios/go_in_action/sample

  • sample
    • data
    • matchers
      • rss.go -- Matcher for searching rss feeds
    • search
      • default.go -- Default matcher for searching data
      • feed.go -- Support for reading the json data file
      • match.go-- Interface support for using different matchers
      • search.go-- Main program logic for performing search
    • main.go -- Programs entry point

The code is organized into these four folders which are listed in alphabetical order. The folder contains a JSON document of data feeds data the program will retrieve and process to match the search term. The matchers folder contains the code for the different types of feeds the program supports. Currently the program only supports one matcher that processes RSS type feeds. The search folder contains the business logic for using the different matchers to search content. Finally we have the parent folder called sample that contains the main.go code file which is the entry point for the program.