Skip to content

Commit 9c82730

Browse files
Reorganizing code for the book
1 parent 1f81572 commit 9c82730

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎chapter2/sample/main.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package main
22

3-
// Using the blank identifier as explicit package name for matchers
4-
// to force the call to the packages init() function.
5-
63
import (
74
_ "github.com/goinaction/code/chapter2/sample/matchers"
85
"github.com/goinaction/code/chapter2/sample/search"

‎chapter2/sample/search/search.go‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ import (
88
// A map of registered matchers for searching.
99
var matchers map[string]Matcher = map[string]Matcher{}
1010

11-
// Register is called to register a matcher for use by the program.
12-
func Register(feedType string, matcher Matcher) {
13-
if _, exists := matchers[feedType]; exists {
14-
log.Fatalln(feedType, "Matcher already registered")
15-
}
16-
17-
log.Println("Register", feedType, "matcher")
18-
matchers[feedType] = matcher
19-
}
20-
2111
// Run performs the search logic.
2212
func Run(searchTerm string) {
2313
// Retrieve the list of feeds to search through.
@@ -65,3 +55,13 @@ func Run(searchTerm string) {
6555
// return after the final result is displayed.
6656
Display(results)
6757
}
58+
59+
// Register is called to register a matcher for use by the program.
60+
func Register(feedType string, matcher Matcher) {
61+
if _, exists := matchers[feedType]; exists {
62+
log.Fatalln(feedType, "Matcher already registered")
63+
}
64+
65+
log.Println("Register", feedType, "matcher")
66+
matchers[feedType] = matcher
67+
}

0 commit comments

Comments
 (0)