lint: enable wastedassign linter (#7340)

This commit is contained in:
Ville Vesilehto 2025-06-02 02:30:41 +03:00 committed by GitHub
parent bb33ab5301
commit 8cac83dfb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 9 additions and 10 deletions

View File

@ -13,6 +13,7 @@ linters:
- unconvert
- unused
- usetesting
- wastedassign
- whitespace
exclusions:
generated: lax

View File

@ -34,14 +34,13 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
// in which upstream doesn't support DNSSEC, the two cache items will effectively be the same. Regardless, any
// DNSSEC RRs in the response are written to cache with the response.
ttl := 0
i := c.getIgnoreTTL(now, state, server)
if i == nil {
crr := &ResponseWriter{ResponseWriter: w, Cache: c, state: state, server: server, do: do, ad: ad, cd: cd,
nexcept: c.nexcept, pexcept: c.pexcept, wildcardFunc: wildcardFunc(ctx)}
return c.doRefresh(ctx, state, crr)
}
ttl = i.ttl(now)
ttl := i.ttl(now)
if ttl < 0 {
// serve stale behavior
if c.verifyStale {

View File

@ -25,7 +25,7 @@ func parseConfig(c *caddy.Controller) ([]*Dnstap, error) {
MultipleTcpWriteBuf: 1,
MultipleQueue: 1,
}
endpoint := ""
d.repl = replacer.New()
args := c.RemainingArgs()
@ -34,7 +34,7 @@ func parseConfig(c *caddy.Controller) ([]*Dnstap, error) {
return nil, c.ArgErr()
}
endpoint = args[0]
endpoint := args[0]
if len(args) >= 3 {
d.MultipleTcpWriteBuf, _ = strconv.Atoi(args[2])

View File

@ -171,7 +171,7 @@ func (h *Hostsfile) parse(r io.Reader) *Map {
continue
}
family := 0
var family int
if addr.To4() != nil {
family = 1
} else {

View File

@ -379,7 +379,8 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
}
zonePath := msg.Path(zone, coredns)
ip := ""
var ip string
if strings.Count(podname, "-") == 3 && !strings.Contains(podname, "--") {
ip = strings.ReplaceAll(podname, "-", ".")
} else {

View File

@ -11,10 +11,8 @@ import (
// 54.119.58.176.in-addr.arpa. becomes 176.58.119.54. If the conversion
// fails the empty string is returned.
func ExtractAddressFromReverse(reverseName string) string {
search := ""
f := reverse
var search string
switch {
case strings.HasSuffix(reverseName, IP4arpa):
search = strings.TrimSuffix(reverseName, IP4arpa)

View File

@ -107,7 +107,7 @@ func (t *Transport) Dial(proto string) (*persistConn, bool, error) {
func (p *Proxy) Connect(ctx context.Context, state request.Request, opts Options) (*dns.Msg, error) {
start := time.Now()
proto := ""
var proto string
switch {
case opts.ForceTCP: // TCP flag has precedence over UDP flag
proto = "tcp"