plugin: cleanup code based on staticcheck warnings (#3302)
TrimPrefix re-assign to former variable Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
This commit is contained in:
parent
47719756fe
commit
eb59e79207
5 changed files with 6 additions and 10 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 + "/"
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue