From 093d6879d080a2e651f29c97cec96831e7deb92d Mon Sep 17 00:00:00 2001 From: Samuel Hawksby-Robinson Date: Tue, 5 Jan 2021 00:13:06 +0000 Subject: [PATCH] Replaced main found map with struct slice to keep discovery order --- main.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index ca186a6..a221606 100644 --- a/main.go +++ b/main.go @@ -12,10 +12,19 @@ const ( ignore = statusDir + "/vendor" ) +// TODO implement dynamic comment token selection +// TODO implement dynamic todo phrase search generation +// ie generate regex string from a slice of keywords + var ( - found = map[string][]string{} + found []todo ) +type todo struct { + Filepath string + Description string +} + func main() { err := processFilesInDir(statusDir) if err != nil { @@ -26,7 +35,7 @@ func main() { } func processFilesInDir(dir string) error { - r, err := regexp.Compile("//.*([t,T][o,O][d,D][o,O]|[f,F][i,I][x,X][m,M][e,E])(.*)[\n,\r,\n\r,\r\n]") + r, err := regexp.Compile("//.*(([t,T][o,O][d,D][o,O]|[f,F][i,I][x,X][m,M][e,E])(.*))[\n,\r,\n\r,\r\n]") if err != nil { return err } @@ -64,12 +73,9 @@ func processFilesInDir(dir string) error { continue } - found[filepath] = []string{} - - //spew.Dump(filepath, results) for _, rst := range results { spew.Dump(rst) - found[filepath] = append(found[filepath], string(rst[2])) + found = append(found, todo{filepath, string(rst[1])}) } }