From d31f1735d9eb5eabe0ada5be31aef281aab3056c Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Fri, 7 Jun 2019 21:24:26 +0200 Subject: [PATCH] Use fmt.Errorf for creating error with formatting (#5968) --- plugins/inputs/dns_query/dns_query.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/inputs/dns_query/dns_query.go b/plugins/inputs/dns_query/dns_query.go index 3fcf4a0b8..b33e508ea 100644 --- a/plugins/inputs/dns_query/dns_query.go +++ b/plugins/inputs/dns_query/dns_query.go @@ -1,7 +1,6 @@ package dns_query import ( - "errors" "fmt" "net" "strconv" @@ -162,7 +161,7 @@ func (d *DnsQuery) getDnsQueryTime(domain string, server string) (float64, int, func (d *DnsQuery) parseRecordType() (uint16, error) { var recordType uint16 - var error error + var err error switch d.RecordType { case "A": @@ -188,10 +187,10 @@ func (d *DnsQuery) parseRecordType() (uint16, error) { case "TXT": recordType = dns.TypeTXT default: - error = errors.New(fmt.Sprintf("Record type %s not recognized", d.RecordType)) + err = fmt.Errorf("Record type %s not recognized", d.RecordType) } - return recordType, error + return recordType, err } func setResult(result ResultType, fields map[string]interface{}, tags map[string]string) {