Extract countDNSEntries function

This commit is contained in:
Bryan Boreham committed 2016-10-20 13:54:42 +01:00
1 parent 1092bae05c
commit 71d550260f
1 file changed
+11 -9
+11 -9
View File
@@ -20,15 +20,7 @@ import (
)
var rootTemplate = template.New("root").Funcs(map[string]interface{}{
"countDNSEntries": func(entries []nameserver.EntryStatus) int {
count := 0
for _, entry := range entries {
if entry.Tombstone == 0 {
count++
}
}
return count
},
"countDNSEntries": countDNSEntries,
"printList": func(list []string) string {
if len(list) == 0 {
return "none"
@@ -118,6 +110,16 @@ var rootTemplate = template.New("root").Funcs(map[string]interface{}{
"trimSuffix": strings.TrimSuffix,
})
func countDNSEntries(entries []nameserver.EntryStatus) int {
count := 0
for _, entry := range entries {
if entry.Tombstone == 0 {
count++
}
}
return count
}
// Print counts in a specified order
func printCounts(counts map[string]int, keys []string) string {
var stringCounts []string