add golangci-lint linter (#5499)

This commit is contained in:
Ondřej Benkovský
2022-07-10 20:06:33 +02:00
committed by GitHub
parent abc5ac8017
commit c2dbb7141a
104 changed files with 83 additions and 184 deletions

View File

@@ -38,7 +38,7 @@ func Split(n *net.IPNet) []string {
func nets(network *net.IPNet, newPrefixLen int) []*net.IPNet {
prefixLen, _ := network.Mask.Size()
maxSubnets := int(math.Exp2(float64(newPrefixLen)) / math.Exp2(float64(prefixLen)))
nets := []*net.IPNet{{network.IP, net.CIDRMask(newPrefixLen, 8*len(network.IP))}}
nets := []*net.IPNet{{IP: network.IP, Mask: net.CIDRMask(newPrefixLen, 8*len(network.IP))}}
for i := 1; i < maxSubnets; i++ {
next, exceeds := cidr.NextSubnet(nets[len(nets)-1], newPrefixLen)

View File

@@ -19,7 +19,6 @@ func TestMultiWriteMsg(t *testing.T) {
if len(record.Msgs) != 2 {
t.Fatalf("Expected 2 messages to be written, but instead found %d\n", len(record.Msgs))
}
if record.Len != responseTestMsg.Len()*2 {
t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", responseTestMsg.Len()*2, record.Len)

View File

@@ -66,6 +66,5 @@ func TestIsReverse(t *testing.T) {
if got != tc.expected {
t.Errorf("Test %d, got %d, expected %d for %s", i, got, tc.expected, tc.name)
}
}
}

View File

@@ -32,7 +32,6 @@ func stripZone(host string) string {
func HostPortOrFile(s ...string) ([]string, error) {
var servers []string
for _, h := range s {
trans, host := Transport(h)
addr, _, err := net.SplitHostPort(host)

View File

@@ -32,5 +32,4 @@ func (r *Rand) Perm(n int) []int {
v := r.r.Perm(n)
r.m.Unlock()
return v
}

View File

@@ -271,6 +271,7 @@ func (r replacer) Replace(ctx context.Context, state request.Request, rr *dnstes
}
}
s := string(b)
//nolint:staticcheck
bufPool.Put(b[:0])
return s
}

View File

@@ -276,7 +276,6 @@ func BenchmarkReplacer(b *testing.B) {
}
func BenchmarkReplacer_CommonLogFormat(b *testing.B) {
w := dnstest.NewRecorder(&test.ResponseWriter{})
r := new(dns.Msg)
r.SetQuestion("example.org.", dns.TypeHINFO)