Moved TodoFinder.init() to NewTodoFinder func to ensure init is not forgotten
This commit is contained in:
parent
4723f2f47d
commit
2e514a4d9c
3
main.go
3
main.go
|
@ -14,8 +14,7 @@ const (
|
|||
)
|
||||
|
||||
func main() {
|
||||
tf := NewTodoFinder()
|
||||
err := tf.Init()
|
||||
tf, err := NewTodoFinder()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -24,15 +24,17 @@ type TodoFinder struct {
|
|||
keywords []string
|
||||
}
|
||||
|
||||
func NewTodoFinder() TodoFinder {
|
||||
return TodoFinder{
|
||||
func NewTodoFinder() (TodoFinder, error) {
|
||||
tf := TodoFinder{
|
||||
FoundTable: []*todo{},
|
||||
foundTree: &node{Name: "root", Type: "dir"},
|
||||
keywords: []string{"todo", "fixme"},
|
||||
}
|
||||
|
||||
return tf, tf.init()
|
||||
}
|
||||
|
||||
func (tf *TodoFinder) Init() (err error) {
|
||||
func (tf *TodoFinder) init() (err error) {
|
||||
tf.todoRegex, err = regexp.Compile(tf.buildRegexPattern())
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue