diff options
author | 2019-09-25 20:23:43 +0800 | |
---|---|---|
committer | 2019-09-25 13:23:43 +0100 | |
commit | eb59e79207446dcf8f80c4fa5715b6a181b13013 (patch) | |
tree | 27bbec74e292c7e1e0b07ab988e97dce3c291bba /plugin | |
parent | 47719756fed4946db4b1d3e9ca36d09e2c360cad (diff) | |
download | coredns-eb59e79207446dcf8f80c4fa5715b6a181b13013.tar.gz coredns-eb59e79207446dcf8f80c4fa5715b6a181b13013.tar.zst coredns-eb59e79207446dcf8f80c4fa5715b6a181b13013.zip |
plugin: cleanup code based on staticcheck warnings (#3302)
TrimPrefix re-assign to former variable
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/acl/acl_test.go | 4 | ||||
-rw-r--r-- | plugin/dnstap/setup.go | 4 | ||||
-rw-r--r-- | plugin/etcd/etcd.go | 2 | ||||
-rw-r--r-- | plugin/file/xfr.go | 2 | ||||
-rw-r--r-- | plugin/hosts/hostsfile.go | 4 |
5 files changed, 6 insertions, 10 deletions
diff --git a/plugin/acl/acl_test.go b/plugin/acl/acl_test.go index 9b23edc53..ff3d86e1a 100644 --- a/plugin/acl/acl_test.go +++ b/plugin/acl/acl_test.go @@ -27,9 +27,7 @@ func (t *testResponseWriter) WriteMsg(m *dns.Msg) error { func NewTestControllerWithZones(input string, zones []string) *caddy.Controller { ctr := caddy.NewTestController("dns", input) - for _, zone := range zones { - ctr.ServerBlockKeys = append(ctr.ServerBlockKeys, zone) - } + ctr.ServerBlockKeys = append(ctr.ServerBlockKeys, zones...) return ctr } diff --git a/plugin/dnstap/setup.go b/plugin/dnstap/setup.go index 5baec5c6e..06f26428c 100644 --- a/plugin/dnstap/setup.go +++ b/plugin/dnstap/setup.go @@ -46,9 +46,7 @@ func parseConfig(d *caddyfile.Dispenser) (c config, err error) { c.target = servers[0] } else { // default to UNIX socket - if strings.HasPrefix(c.target, "unix://") { - c.target = c.target[7:] - } + c.target = strings.TrimPrefix(c.target, "unix://") c.socket = true } diff --git a/plugin/etcd/etcd.go b/plugin/etcd/etcd.go index a39cb0e62..305e8e492 100644 --- a/plugin/etcd/etcd.go +++ b/plugin/etcd/etcd.go @@ -83,7 +83,7 @@ func (e *Etcd) Records(ctx context.Context, state request.Request, exact bool) ( func (e *Etcd) get(ctx context.Context, path string, recursive bool) (*etcdcv3.GetResponse, error) { ctx, cancel := context.WithTimeout(ctx, etcdTimeout) defer cancel() - if recursive == true { + if recursive { if !strings.HasSuffix(path, "/") { path = path + "/" } diff --git a/plugin/file/xfr.go b/plugin/file/xfr.go index 659c5c9c3..f7192165b 100644 --- a/plugin/file/xfr.go +++ b/plugin/file/xfr.go @@ -45,8 +45,8 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in ch := make(chan *dns.Envelope) tr := new(dns.Transfer) wg := new(sync.WaitGroup) + wg.Add(1) go func() { - wg.Add(1) tr.Out(w, r, ch) wg.Done() }() diff --git a/plugin/hosts/hostsfile.go b/plugin/hosts/hostsfile.go index ed9763de1..19cb7e7b3 100644 --- a/plugin/hosts/hostsfile.go +++ b/plugin/hosts/hostsfile.go @@ -244,8 +244,8 @@ func (h *Hostsfile) LookupStaticAddr(addr string) []string { h.RLock() defer h.RUnlock() - hosts1, _ := h.hmap.addr[addr] - hosts2, _ := h.inline.addr[addr] + hosts1 := h.hmap.addr[addr] + hosts2 := h.inline.addr[addr] if len(hosts1) == 0 && len(hosts2) == 0 { return nil |