Replaced main found map with struct slice to keep discovery order

This commit is contained in:
Samuel Hawksby-Robinson 2021-01-05 00:13:06 +00:00
parent d8c006bf39
commit 093d6879d0
No known key found for this signature in database
GPG Key ID: 64CF99D4A64A1205
1 changed files with 12 additions and 6 deletions

18
main.go
View File

@ -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])})
}
}