Skip to content

Commit b08184c

Browse files
refactored to use a nil pointer for registering matchers
1 parent a550d03 commit b08184c

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎chapter2/sample/matchers/rss.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ type rssMatcher struct{}
5858

5959
// init registeres the matcher with the program.
6060
func init() {
61-
search.Register("rss", &rssMatcher{})
61+
var matcher *rssMatcher
62+
search.Register("rss", matcher)
6263
}
6364

6465
// Search looks at the document for the specified search term.

‎chapter2/sample/search/default.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ type defaultMatcher struct{}
55

66
// init registeres the default matcher with the program.
77
func init() {
8-
Register("default", &defaultMatcher{})
8+
var matcher *defaultMatcher
9+
Register("default", matcher)
910
}
1011

1112
// Search implements the behavior for the default matcher.

0 commit comments

Comments
 (0)