diff --git a/ipam/ring/ring.go b/ipam/ring/ring.go index 43322a7f..e1cb1bcd 100644 --- a/ipam/ring/ring.go +++ b/ipam/ring/ring.go @@ -560,7 +560,7 @@ func (r *Ring) ChoosePeersToAskForSpace(start, end address.Address) []mesh.PeerN break } // Ignore ranges with no free space - if entry.Free <= 0 { + if entry.Free == 0 { continue } diff --git a/ipam/space/space_test.go b/ipam/space/space_test.go index 1c00060e..e123287d 100644 --- a/ipam/space/space_test.go +++ b/ipam/space/space_test.go @@ -73,7 +73,7 @@ func TestLowlevel(t *testing.T) { // test Donate when addresses are scarce s = New() - r, ok = s.Donate(address.NewRange(0, 1000)) + _, ok = s.Donate(address.NewRange(0, 1000)) require.True(t, !ok, "donate on empty space should fail") s.Add(0, 3) require.NoError(t, s.Claim(0)) @@ -81,7 +81,7 @@ func TestLowlevel(t *testing.T) { r, ok = s.Donate(address.NewRange(0, 1000)) require.True(t, ok, "donate") require.Equal(t, address.NewRange(1, 1), r, "donate") - r, ok = s.Donate(address.NewRange(0, 1000)) + _, ok = s.Donate(address.NewRange(0, 1000)) require.True(t, !ok, "donate should fail") } diff --git a/npc/selector.go b/npc/selector.go index e6738a30..dfe73aee 100644 --- a/npc/selector.go +++ b/npc/selector.go @@ -59,7 +59,7 @@ func (spec *selectorSpec) getRuleSpec(src bool) ([]string, string) { } rule := []string{"-m", "set", "--match-set", string(spec.ipsetName), dir} - comment := "anywhere" + var comment string if spec.nsName != "" { comment = fmt.Sprintf("pods: namespace: %s, selector: %s", spec.nsName, spec.key) } else { diff --git a/prog/kube-utils/main.go b/prog/kube-utils/main.go index 6803ff11..fe1f05f2 100644 --- a/prog/kube-utils/main.go +++ b/prog/kube-utils/main.go @@ -370,7 +370,7 @@ func main() { } if runReclaimDaemon { // Handle SIGINT and SIGTERM - ch := make(chan os.Signal) + ch := make(chan os.Signal, 1) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) stopCh := make(chan struct{}) rand.Seed(time.Now().UnixNano()) diff --git a/proxy/common.go b/proxy/common.go index 88dd8354..280cc0c8 100644 --- a/proxy/common.go +++ b/proxy/common.go @@ -15,7 +15,7 @@ import ( ) var ( - containerIDRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/([^/]*)/.*") + containerIDRegexp = regexp.MustCompile(`^(/v[0-9.]*)?/containers/([^/]*)/.*`) weaveWaitEntrypoint = []string{"/w/w"} Log = common.Log diff --git a/router/overlay_switch.go b/router/overlay_switch.go index b99d621a..0ef113f7 100644 --- a/router/overlay_switch.go +++ b/router/overlay_switch.go @@ -334,13 +334,13 @@ func (fwd *overlaySwitchForwarder) healthCheck(index int, healthy bool) { fwd.lock.Lock() defer fwd.lock.Unlock() - if healthy == true && fwd.forwarders[index].onHold { + if healthy && fwd.forwarders[index].onHold { log.Debug(fwd.logPrefix(), "Adding "+fwd.forwarders[index].overlayName+" to the list of forwarders") fwd.forwarders[index].onHold = false fwd.chooseBest() } - if healthy == false && !fwd.forwarders[index].onHold { + if !healthy && !fwd.forwarders[index].onHold { log.Debug(fwd.logPrefix(), "Removing "+fwd.forwarders[index].overlayName+" from the list of forwarders") fwd.forwarders[index].onHold = true fwd.chooseBest() diff --git a/router/pcap.go b/router/pcap.go index c4859277..21f84329 100644 --- a/router/pcap.go +++ b/router/pcap.go @@ -147,7 +147,7 @@ func (p *Pcap) sniff(readHandle *pcap.Handle, consumer Consumer) { // in order to prevent the next capture from // overwriting the data pktLen := len(pkt) - pktCopy := make([]byte, pktLen, pktLen) + pktCopy := make([]byte, pktLen) copy(pktCopy, pkt) fop.Process(pktCopy, dec, false)