-
Notifications
You must be signed in to change notification settings - Fork 0
/
csv.go
44 lines (37 loc) · 1.15 KB
/
csv.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package domain
import (
"encoding/csv"
"strconv"
)
func CreateHeaders() []string {
// Number of Columns: 6
return []string{
"ID",
"VirusTotal Analysis Malicious Votes",
"VirusTotal Analysis Suspicious Votes",
"VirusTotal Last Analysis Harmless Votes",
"VirusTotal Last Analysis Undetected Votes",
"VirusTotal Reputation",
}
}
func (_domain Domain) CreateRecord() []string {
// Number of Columns: 6
return []string{
_domain.VirusTotalDomain.Data.Id,
strconv.Itoa(_domain.VirusTotalDomain.Data.Attributes.LastAnalysisStats.Malicious),
strconv.Itoa(_domain.VirusTotalDomain.Data.Attributes.LastAnalysisStats.Suspicious),
strconv.Itoa(_domain.VirusTotalDomain.Data.Attributes.LastAnalysisStats.Harmless),
strconv.Itoa(_domain.VirusTotalDomain.Data.Attributes.LastAnalysisStats.Undetected),
strconv.Itoa(_domain.VirusTotalDomain.Data.Attributes.Reputation),
}
}
func (_domain Domain) WriteRow(w *csv.Writer, createRecord func() []string) error {
return WriteRow(w, createRecord)
}
func WriteRow(w *csv.Writer, createRecord func() []string) error {
defer w.Flush()
if err := w.Write(createRecord()); err != nil {
return err
}
return nil
}