Rename Entry to QEntry in parser.go

This commit is contained in:
Jan Philipp Timme 2018-12-29 18:16:54 +01:00
parent 40c3044c84
commit 063fb5756d

View File

@ -10,7 +10,7 @@ import (
"time" "time"
) )
type Entry struct { type QEntry struct {
id string id string
status string status string
date time.Time date time.Time
@ -20,11 +20,11 @@ type Entry struct {
reason string reason string
} }
func (m Entry) String() string { func (m QEntry) String() string {
return fmt.Sprintf("ID: %s, Status: %s, Size: %d bytes, Sender: %s, Recipients: %d", m.id, m.status, m.size, m.sender, len(m.recipients)) return fmt.Sprintf("ID: %s, Status: %s, Size: %d bytes, Sender: %s, Recipients: %d", m.id, m.status, m.size, m.sender, len(m.recipients))
} }
func ParseMailQ(scanner *bufio.Scanner) ([]Entry, error) { func ParseMailQ(scanner *bufio.Scanner) ([]QEntry, error) {
const dateFormat = "2006 Mon Jan _2 15:04:05" const dateFormat = "2006 Mon Jan _2 15:04:05"
var messageIdStart = regexp.MustCompile("^[0-9A-Za-z]+[*!]? ") var messageIdStart = regexp.MustCompile("^[0-9A-Za-z]+[*!]? ")
scanner.Scan() scanner.Scan()
@ -36,8 +36,8 @@ func ParseMailQ(scanner *bufio.Scanner) ([]Entry, error) {
// Abort if input does not look like output from mailq(1) // Abort if input does not look like output from mailq(1)
return nil, errors.New("Sorry, this does not look like output from mailq(1).") return nil, errors.New("Sorry, this does not look like output from mailq(1).")
} }
var currentMail Entry var currentMail QEntry
var queueEntries []Entry var queueEntries []QEntry
for scanner.Scan() { for scanner.Scan() {
// Read input line by line // Read input line by line
@ -75,7 +75,7 @@ func ParseMailQ(scanner *bufio.Scanner) ([]Entry, error) {
// If the next line is empty, make sure to push current mail to list // If the next line is empty, make sure to push current mail to list
// and create a new struct for the next mail to process // and create a new struct for the next mail to process
queueEntries = append(queueEntries, currentMail) queueEntries = append(queueEntries, currentMail)
currentMail = Entry{} currentMail = QEntry{}
} }
} }
if scanner.Err() != nil { if scanner.Err() != nil {