mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-29 01:04:15 -04:00 
			
		
		
		
	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:
		
				
					committed by
					
						 Miek Gieben
						Miek Gieben
					
				
			
			
				
	
			
			
			
						parent
						
							47719756fe
						
					
				
				
					commit
					eb59e79207
				
			| @@ -27,9 +27,7 @@ func (t *testResponseWriter) WriteMsg(m *dns.Msg) error { | |||||||
|  |  | ||||||
| func NewTestControllerWithZones(input string, zones []string) *caddy.Controller { | func NewTestControllerWithZones(input string, zones []string) *caddy.Controller { | ||||||
| 	ctr := caddy.NewTestController("dns", input) | 	ctr := caddy.NewTestController("dns", input) | ||||||
| 	for _, zone := range zones { | 	ctr.ServerBlockKeys = append(ctr.ServerBlockKeys, zones...) | ||||||
| 		ctr.ServerBlockKeys = append(ctr.ServerBlockKeys, zone) |  | ||||||
| 	} |  | ||||||
| 	return ctr | 	return ctr | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -46,9 +46,7 @@ func parseConfig(d *caddyfile.Dispenser) (c config, err error) { | |||||||
| 		c.target = servers[0] | 		c.target = servers[0] | ||||||
| 	} else { | 	} else { | ||||||
| 		// default to UNIX socket | 		// default to UNIX socket | ||||||
| 		if strings.HasPrefix(c.target, "unix://") { | 		c.target = strings.TrimPrefix(c.target, "unix://") | ||||||
| 			c.target = c.target[7:] |  | ||||||
| 		} |  | ||||||
| 		c.socket = true | 		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) { | func (e *Etcd) get(ctx context.Context, path string, recursive bool) (*etcdcv3.GetResponse, error) { | ||||||
| 	ctx, cancel := context.WithTimeout(ctx, etcdTimeout) | 	ctx, cancel := context.WithTimeout(ctx, etcdTimeout) | ||||||
| 	defer cancel() | 	defer cancel() | ||||||
| 	if recursive == true { | 	if recursive { | ||||||
| 		if !strings.HasSuffix(path, "/") { | 		if !strings.HasSuffix(path, "/") { | ||||||
| 			path = 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) | 	ch := make(chan *dns.Envelope) | ||||||
| 	tr := new(dns.Transfer) | 	tr := new(dns.Transfer) | ||||||
| 	wg := new(sync.WaitGroup) | 	wg := new(sync.WaitGroup) | ||||||
| 	go func() { |  | ||||||
| 	wg.Add(1) | 	wg.Add(1) | ||||||
|  | 	go func() { | ||||||
| 		tr.Out(w, r, ch) | 		tr.Out(w, r, ch) | ||||||
| 		wg.Done() | 		wg.Done() | ||||||
| 	}() | 	}() | ||||||
|   | |||||||
| @@ -244,8 +244,8 @@ func (h *Hostsfile) LookupStaticAddr(addr string) []string { | |||||||
|  |  | ||||||
| 	h.RLock() | 	h.RLock() | ||||||
| 	defer h.RUnlock() | 	defer h.RUnlock() | ||||||
| 	hosts1, _ := h.hmap.addr[addr] | 	hosts1 := h.hmap.addr[addr] | ||||||
| 	hosts2, _ := h.inline.addr[addr] | 	hosts2 := h.inline.addr[addr] | ||||||
|  |  | ||||||
| 	if len(hosts1) == 0 && len(hosts2) == 0 { | 	if len(hosts1) == 0 && len(hosts2) == 0 { | ||||||
| 		return nil | 		return nil | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user