aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Guangming Wang <guangming.wang@daocloud.io> 2019-09-27 18:10:34 +0800
committerGravatar Miek Gieben <miek@miek.nl> 2019-09-27 11:10:34 +0100
commit8af468558766a80af7025d6480389538a1c2c0ea (patch)
tree6e86078fed390fb4e1708b5f0d6ce64918a17381
parentf2df37a1fe87d9a17f31ff8db3ea9c3387d10523 (diff)
downloadcoredns-8af468558766a80af7025d6480389538a1c2c0ea.tar.gz
coredns-8af468558766a80af7025d6480389538a1c2c0ea.tar.zst
coredns-8af468558766a80af7025d6480389538a1c2c0ea.zip
cleanup code by lint (#3312)
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
-rw-r--r--plugin/kubernetes/ns.go3
-rw-r--r--plugin/rewrite/name.go9
-rw-r--r--plugin/rewrite/reverter.go4
-rw-r--r--plugin/rewrite/rewrite_test.go2
-rw-r--r--request/request.go2
5 files changed, 6 insertions, 14 deletions
diff --git a/plugin/kubernetes/ns.go b/plugin/kubernetes/ns.go
index f21890cc9..2d4bc398a 100644
--- a/plugin/kubernetes/ns.go
+++ b/plugin/kubernetes/ns.go
@@ -65,8 +65,7 @@ func (k *Kubernetes) nsAddrs(external bool, zone string) []dns.RR {
}
// Create an RR slice of collected IPs
- var rrs []dns.RR
- rrs = make([]dns.RR, len(svcIPs))
+ rrs := make([]dns.RR, len(svcIPs))
for i, ip := range svcIPs {
if ip.To4() == nil {
rr := new(dns.AAAA)
diff --git a/plugin/rewrite/name.go b/plugin/rewrite/name.go
index e1c2a1114..9302d563a 100644
--- a/plugin/rewrite/name.go
+++ b/plugin/rewrite/name.go
@@ -104,9 +104,7 @@ func (rule *regexNameRule) Rewrite(ctx context.Context, state request.Request) R
s := rule.Replacement
for groupIndex, groupValue := range regexGroups {
groupIndexStr := "{" + strconv.Itoa(groupIndex) + "}"
- if strings.Contains(s, groupIndexStr) {
- s = strings.Replace(s, groupIndexStr, groupValue, -1)
- }
+ s = strings.Replace(s, groupIndexStr, groupValue, -1)
}
state.Req.Question[0].Name = s
return RewriteDone
@@ -264,10 +262,7 @@ func (rule *regexNameRule) GetResponseRule() ResponseRule { return rule.Response
// hasClosingDot return true if s has a closing dot at the end.
func hasClosingDot(s string) bool {
- if strings.HasSuffix(s, ".") {
- return true
- }
- return false
+ return strings.HasSuffix(s, ".")
}
// getSubExprUsage return the number of subexpressions used in s.
diff --git a/plugin/rewrite/reverter.go b/plugin/rewrite/reverter.go
index 5a55c7ad5..00e41454e 100644
--- a/plugin/rewrite/reverter.go
+++ b/plugin/rewrite/reverter.go
@@ -59,9 +59,7 @@ func (r *ResponseReverter) WriteMsg(res *dns.Msg) error {
s := rule.Replacement
for groupIndex, groupValue := range regexGroups {
groupIndexStr := "{" + strconv.Itoa(groupIndex) + "}"
- if strings.Contains(s, groupIndexStr) {
- s = strings.Replace(s, groupIndexStr, groupValue, -1)
- }
+ s = strings.Replace(s, groupIndexStr, groupValue, -1)
}
name = s
isNameRewritten = true
diff --git a/plugin/rewrite/rewrite_test.go b/plugin/rewrite/rewrite_test.go
index 316921954..ecab07787 100644
--- a/plugin/rewrite/rewrite_test.go
+++ b/plugin/rewrite/rewrite_test.go
@@ -422,7 +422,7 @@ func optsEqual(a, b []dns.EDNS0) bool {
if aa.SourceScope != bb.SourceScope {
return false
}
- if !bytes.Equal(aa.Address, bb.Address) {
+ if !aa.Address.Equal(bb.Address) {
return false
}
} else {
diff --git a/request/request.go b/request/request.go
index 0ce34816c..6f1a1de0e 100644
--- a/request/request.go
+++ b/request/request.go
@@ -358,7 +358,7 @@ func (r *Request) Match(reply *dns.Msg) bool {
return false
}
- if reply.Response == false {
+ if !reply.Response {
return false
}