aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Zhizhen He <hezhizhen.yi@gmail.com> 2023-08-14 21:14:09 +0800
committerGravatar GitHub <noreply@github.com> 2023-08-14 15:14:09 +0200
commit5de473da1c6245c983fe05bbaba1a5683b4f3e32 (patch)
treef02c406536f5288ae602ad5ef355d45e3e1a3b0d
parent141c760846df094e0dd5078aab8559c28c5a9644 (diff)
downloadcoredns-5de473da1c6245c983fe05bbaba1a5683b4f3e32.tar.gz
coredns-5de473da1c6245c983fe05bbaba1a5683b4f3e32.tar.zst
coredns-5de473da1c6245c983fe05bbaba1a5683b4f3e32.zip
fix: remove unnecessary conversion (#6258)
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
-rw-r--r--.golangci.yml1
-rw-r--r--plugin/azure/azure_test.go2
-rw-r--r--plugin/chaos/chaos_test.go2
-rw-r--r--plugin/clouddns/clouddns_test.go2
-rw-r--r--plugin/dnssec/black_lies_bitmap_test.go4
-rw-r--r--plugin/erratic/erratic_test.go4
-rw-r--r--plugin/hosts/hostsfile.go2
-rw-r--r--plugin/kubernetes/external.go4
-rw-r--r--plugin/kubernetes/xfr.go4
-rw-r--r--plugin/loadbalance/weighted.go2
-rw-r--r--plugin/nsid/nsid_test.go2
-rw-r--r--plugin/pkg/dnsutil/ttl_test.go4
-rw-r--r--plugin/rewrite/wire.go2
-rw-r--r--plugin/route53/route53_test.go2
-rw-r--r--plugin/whoami/whoami_test.go2
15 files changed, 20 insertions, 19 deletions
diff --git a/.golangci.yml b/.golangci.yml
index cc84a8102..20a45f5ef 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -10,3 +10,4 @@ linters:
- whitespace
- unused
- gofmt
+ - unconvert
diff --git a/plugin/azure/azure_test.go b/plugin/azure/azure_test.go
index d308313a8..017830001 100644
--- a/plugin/azure/azure_test.go
+++ b/plugin/azure/azure_test.go
@@ -145,7 +145,7 @@ func TestAzure(t *testing.T) {
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
}
- if code != int(tc.wantRetCode) {
+ if code != tc.wantRetCode {
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
}
diff --git a/plugin/chaos/chaos_test.go b/plugin/chaos/chaos_test.go
index 12cc1697e..e5d4a55aa 100644
--- a/plugin/chaos/chaos_test.go
+++ b/plugin/chaos/chaos_test.go
@@ -65,7 +65,7 @@ func TestChaos(t *testing.T) {
if err != tc.expectedErr {
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
}
- if code != int(tc.expectedCode) {
+ if code != tc.expectedCode {
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
}
if tc.expectedReply != "" {
diff --git a/plugin/clouddns/clouddns_test.go b/plugin/clouddns/clouddns_test.go
index f8a7a9d09..829aa71b0 100644
--- a/plugin/clouddns/clouddns_test.go
+++ b/plugin/clouddns/clouddns_test.go
@@ -292,7 +292,7 @@ func TestCloudDNS(t *testing.T) {
if err != tc.expectedErr {
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
}
- if code != int(tc.wantRetCode) {
+ if code != tc.wantRetCode {
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
}
diff --git a/plugin/dnssec/black_lies_bitmap_test.go b/plugin/dnssec/black_lies_bitmap_test.go
index ebc18997f..4e9a10cf6 100644
--- a/plugin/dnssec/black_lies_bitmap_test.go
+++ b/plugin/dnssec/black_lies_bitmap_test.go
@@ -28,7 +28,7 @@ func TestBlackLiesBitmapNoData(t *testing.T) {
}
}
for _, b := range nsec.TypeBitMap {
- if uint16(b) == dns.TypeTLSA {
+ if b == dns.TypeTLSA {
t.Errorf("Type TLSA should not be present in the type bitmap: %v", nsec.TypeBitMap)
}
}
@@ -50,7 +50,7 @@ func TestBlackLiesBitmapNameError(t *testing.T) {
}
}
for _, b := range nsec.TypeBitMap {
- if uint16(b) == dns.TypeTLSA {
+ if b == dns.TypeTLSA {
t.Errorf("Type TLSA should not be present in the type bitmap: %v", nsec.TypeBitMap)
}
}
diff --git a/plugin/erratic/erratic_test.go b/plugin/erratic/erratic_test.go
index ec2ec5c0a..de8dbe4d6 100644
--- a/plugin/erratic/erratic_test.go
+++ b/plugin/erratic/erratic_test.go
@@ -37,7 +37,7 @@ func TestErraticDrop(t *testing.T) {
if err != tc.expectedErr {
t.Errorf("Test %d: Expected error %q, but got %q", i, tc.expectedErr, err)
}
- if code != int(tc.expectedCode) {
+ if code != tc.expectedCode {
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
}
@@ -71,7 +71,7 @@ func TestErraticTruncate(t *testing.T) {
if err != tc.expectedErr {
t.Errorf("Test %d: Expected error %q, but got %q", i, tc.expectedErr, err)
}
- if code != int(tc.expectedCode) {
+ if code != tc.expectedCode {
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
}
diff --git a/plugin/hosts/hostsfile.go b/plugin/hosts/hostsfile.go
index cf3c43cc8..e5aff0d6d 100644
--- a/plugin/hosts/hostsfile.go
+++ b/plugin/hosts/hostsfile.go
@@ -45,7 +45,7 @@ func newOptions() *options {
return &options{
autoReverse: true,
ttl: 3600,
- reload: time.Duration(5 * time.Second),
+ reload: 5 * time.Second,
}
}
diff --git a/plugin/kubernetes/external.go b/plugin/kubernetes/external.go
index 19a8e665e..f6705d22f 100644
--- a/plugin/kubernetes/external.go
+++ b/plugin/kubernetes/external.go
@@ -187,7 +187,7 @@ func (k *Kubernetes) ExternalServices(zone string, headless bool) (services []ms
continue
}
s.Host = msg.Domain(s.Key)
- s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/")
+ s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+p.Protocol), strings.ToLower("_"+p.Name)), "/")
headlessServices[strings.Join([]string{s.Key, PortProtocol}, "/")] = append(headlessServices[strings.Join([]string{s.Key, PortProtocol}, "/")], s)
}
}
@@ -200,7 +200,7 @@ func (k *Kubernetes) ExternalServices(zone string, headless bool) (services []ms
s := msg.Service{Host: ip, Port: int(p.Port), TTL: k.ttl}
s.Key = strings.Join([]string{zonePath, svc.Namespace, svc.Name}, "/")
services = append(services, s)
- s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/")
+ s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+p.Name)), "/")
s.TargetStrip = 2
services = append(services, s)
}
diff --git a/plugin/kubernetes/xfr.go b/plugin/kubernetes/xfr.go
index 1990bea40..4d941a96e 100644
--- a/plugin/kubernetes/xfr.go
+++ b/plugin/kubernetes/xfr.go
@@ -89,7 +89,7 @@ func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, erro
continue
}
- s.Key = strings.Join(append(svcBase, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/")
+ s.Key = strings.Join(append(svcBase, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+p.Name)), "/")
ch <- []dns.RR{s.NewSRV(msg.Domain(s.Key), 100)}
}
@@ -124,7 +124,7 @@ func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, erro
s.Port = int(p.Port)
- s.Key = strings.Join(append(svcBase, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/")
+ s.Key = strings.Join(append(svcBase, strings.ToLower("_"+p.Protocol), strings.ToLower("_"+p.Name)), "/")
ch <- []dns.RR{s.NewSRV(msg.Domain(s.Key), srvWeight)}
}
}
diff --git a/plugin/loadbalance/weighted.go b/plugin/loadbalance/weighted.go
index 2622509f4..39b178017 100644
--- a/plugin/loadbalance/weighted.go
+++ b/plugin/loadbalance/weighted.go
@@ -199,7 +199,7 @@ func (w *weightedRR) topAddressIndex(address []dns.RR) int {
for _, wa := range weightedAddr {
psum += uint(wa.weight)
if v < psum {
- return int(wa.index)
+ return wa.index
}
}
diff --git a/plugin/nsid/nsid_test.go b/plugin/nsid/nsid_test.go
index eda45302e..c6268b409 100644
--- a/plugin/nsid/nsid_test.go
+++ b/plugin/nsid/nsid_test.go
@@ -119,7 +119,7 @@ func TestNsidCache(t *testing.T) {
if err != tc.expectedErr {
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
}
- if code != int(tc.expectedCode) {
+ if code != tc.expectedCode {
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
}
if tc.expectedReply != "" {
diff --git a/plugin/pkg/dnsutil/ttl_test.go b/plugin/pkg/dnsutil/ttl_test.go
index 7dab65cb7..0f49bf5f5 100644
--- a/plugin/pkg/dnsutil/ttl_test.go
+++ b/plugin/pkg/dnsutil/ttl_test.go
@@ -26,7 +26,7 @@ func TestMinimalTTL(t *testing.T) {
t.Fatalf("Expected type to be response.NoData, got %s", mt)
}
dur := MinimalTTL(m, mt) // minTTL on msg is 3600 (neg. ttl on SOA)
- if dur != time.Duration(1800*time.Second) {
+ if dur != 1800*time.Second {
t.Fatalf("Expected minttl duration to be %d, got %d", 1800, dur)
}
@@ -36,7 +36,7 @@ func TestMinimalTTL(t *testing.T) {
t.Fatalf("Expected type to be response.NameError, got %s", mt)
}
dur = MinimalTTL(m, mt) // minTTL on msg is 3600 (neg. ttl on SOA)
- if dur != time.Duration(1800*time.Second) {
+ if dur != 1800*time.Second {
t.Fatalf("Expected minttl duration to be %d, got %d", 1800, dur)
}
}
diff --git a/plugin/rewrite/wire.go b/plugin/rewrite/wire.go
index 11b4dac05..df25f7faa 100644
--- a/plugin/rewrite/wire.go
+++ b/plugin/rewrite/wire.go
@@ -21,7 +21,7 @@ func ipToWire(family int, ipAddr string) ([]byte, error) {
// uint16ToWire writes unit16 to wire/binary format
func uint16ToWire(data uint16) []byte {
buf := make([]byte, 2)
- binary.BigEndian.PutUint16(buf, uint16(data))
+ binary.BigEndian.PutUint16(buf, data)
return buf
}
diff --git a/plugin/route53/route53_test.go b/plugin/route53/route53_test.go
index 414a691be..d9b2fa102 100644
--- a/plugin/route53/route53_test.go
+++ b/plugin/route53/route53_test.go
@@ -231,7 +231,7 @@ func TestRoute53(t *testing.T) {
if err != tc.expectedErr {
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
}
- if code != int(tc.wantRetCode) {
+ if code != tc.wantRetCode {
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
}
diff --git a/plugin/whoami/whoami_test.go b/plugin/whoami/whoami_test.go
index 055f267a4..fa6a6f0fa 100644
--- a/plugin/whoami/whoami_test.go
+++ b/plugin/whoami/whoami_test.go
@@ -66,7 +66,7 @@ func TestWhoami(t *testing.T) {
if err != tc.expectedErr {
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
}
- if code != int(tc.expectedCode) {
+ if code != tc.expectedCode {
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
}
if len(tc.expectedReply) != 0 {