Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Clean up some lint warnings
Browse files Browse the repository at this point in the history
I ran golangci-lint and it pointed out a few things to clean up.
  • Loading branch information
bboreham committed Jul 31, 2020
1 parent 28e482a commit 34dc4da
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ipam/ring/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions ipam/space/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ 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))
require.NoError(t, s.Claim(2))
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")
}

Expand Down
2 changes: 1 addition & 1 deletion npc/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion prog/kube-utils/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion proxy/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions router/overlay_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion router/pcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 34dc4da

Please sign in to comment.