From d54fd77204cc1e9444085ca13b87953bf096fff8 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Mon, 3 Dec 2018 16:42:04 +0300 Subject: [PATCH] Fix linter warnings. --- coredns_plugin/coredns_plugin.go | 26 +++++++++++++------------- coredns_plugin/coredns_stats.go | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/coredns_plugin/coredns_plugin.go b/coredns_plugin/coredns_plugin.go index 5b09c91..7ed8031 100644 --- a/coredns_plugin/coredns_plugin.go +++ b/coredns_plugin/coredns_plugin.go @@ -120,12 +120,12 @@ func setupPlugin(c *caddy.Controller) (*plug, error) { if !c.NextArg() { return nil, c.ArgErr() } - blockedTtl, err := strconv.ParseUint(c.Val(), 10, 32) + blockedTTL, err := strconv.ParseUint(c.Val(), 10, 32) if err != nil { return nil, c.ArgErr() } - log.Printf("Blocked request TTL is %d", blockedTtl) - p.settings.BlockedTTL = uint32(blockedTtl) + log.Printf("Blocked request TTL is %d", blockedTTL) + p.settings.BlockedTTL = uint32(blockedTTL) case "querylog": log.Println("Query log is enabled") p.settings.QueryLogEnabled = true @@ -134,7 +134,7 @@ func setupPlugin(c *caddy.Controller) (*plug, error) { return nil, c.ArgErr() } - filterId, err := strconv.ParseInt(c.Val(), 10, 64) + filterID, err := strconv.ParseInt(c.Val(), 10, 64) if err != nil { return nil, c.ArgErr() } @@ -145,7 +145,7 @@ func setupPlugin(c *caddy.Controller) (*plug, error) { // Initialize filter and add it to the list p.settings.Filters = append(p.settings.Filters, plugFilter{ - ID: filterId, + ID: filterID, Path: filterPath, }) } @@ -288,7 +288,7 @@ func (p *plug) Collect(ch chan<- prometheus.Metric) { // lookup host, but return answer as if it was a result of origname lookup func lookupReplaced(host string, origname string) ([]dns.RR, error) { var records []dns.RR - var res *net.Resolver = nil // nil resolver is default resolver + var res *net.Resolver // nil resolver is default resolver addrs, err := res.LookupIPAddr(context.TODO(), host) if err != nil { return nil, err @@ -445,14 +445,14 @@ func (p *plug) serveDNSInternal(ctx context.Context, w dns.ResponseWriter, r *dn return rcode, dnsfilter.Result{}, err } return rcode, result, err - } else { - // This is a hosts-syntax rule - rcode, err := p.replaceHostWithValAndReply(ctx, w, r, host, result.Ip.String(), question) - if err != nil { - return rcode, dnsfilter.Result{}, err - } - return rcode, result, err } + + // This is a hosts-syntax rule + rcode, err := p.replaceHostWithValAndReply(ctx, w, r, host, result.Ip.String(), question) + if err != nil { + return rcode, dnsfilter.Result{}, err + } + return rcode, result, err case dnsfilter.FilteredInvalid: // return NXdomain rcode, err := p.writeNXdomain(ctx, w, r) diff --git a/coredns_plugin/coredns_stats.go b/coredns_plugin/coredns_stats.go index 2928513..6c3de19 100644 --- a/coredns_plugin/coredns_stats.go +++ b/coredns_plugin/coredns_stats.go @@ -90,7 +90,7 @@ func (p *periodicStats) Observe(name string, when time.Time, value float64) { currentValues := p.Entries[countname] value := currentValues[elapsed] // trace("Will change p.Entries[%s][%d] from %v to %v", countname, elapsed, value, value+1) - value += 1 + value++ currentValues[elapsed] = value p.Entries[countname] = currentValues }