diff --git a/cmd/add.go b/cmd/add.go index 9ca8ece..70e4f33 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -104,9 +104,9 @@ func parseGrepLine(line string) (*model.Ticket, error) { text := strings.Join(parts[2:], "") return &model.Ticket{ - Filename: filename, - LineNo: lineNo, - Text: text, + "filename": filename, + "lineNo": lineNo, + "text": text, }, nil } diff --git a/model/ticket.go b/model/ticket.go index 73479d9..974dedd 100644 --- a/model/ticket.go +++ b/model/ticket.go @@ -4,21 +4,17 @@ import ( "fmt" ) -type Ticket struct { - Filename string `json:"filename"` - LineNo int `json:"line_no"` - Text string `json:"text"` -} +type Ticket map[string]interface{} func RemoveDuplicateTickets(tickets []*Ticket, fileOnly bool) []*Ticket { ticketMap := map[string]*Ticket{} for _, t := range tickets { + filename, _ := (*t)["filename"].(string) + lineNo, _ := (*t)["lineNo"].(int) if fileOnly { - t.Text = "" - t.LineNo = 0 - ticketMap[t.Filename] = t + ticketMap[filename] = t } else { - ticketMap[fmt.Sprintf("%s:%d", t.Filename, t.LineNo)] = t + ticketMap[fmt.Sprintf("%s:%d", filename, lineNo)] = t } }