Skip to content

Commit 8e6030e

Browse files
authored
Merge pull request #3 from randlabs/staticcheck
Applied Static-check tool
2 parents 352764d + c6778e4 commit 8e6030e

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

httpclient/httpclient.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ func (c *HttpClient) AddSource(baseURL string, header http.Header, opts loadbala
8080
}
8181

8282
// Remove trailing slash
83-
if strings.HasSuffix(baseURL, "/") {
84-
baseURL = baseURL[0 : len(baseURL)-1]
85-
}
83+
baseURL = strings.TrimSuffix(baseURL, "/")
8684

8785
// Add source to list
8886
src := newSource(len(c.sources) + 1, baseURL, header, opts.IsBackup)

httpclient/internal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// -----------------------------------------------------------------------------
1010

11-
var serverDownErr = errors.New("server down")
11+
var errServerDown = errors.New("server down")
1212

1313
// -----------------------------------------------------------------------------
1414

@@ -26,7 +26,7 @@ func (c *HttpClient) balancerEventHandler(eventType int, srv *balancer.Server) {
2626
case balancer.ServerDownEvent:
2727
src.setOnlineStatus(false)
2828
if c.eventHandler != nil {
29-
c.eventHandler(ServerDownEvent, src.ID(), serverDownErr)
29+
c.eventHandler(ServerDownEvent, src.ID(), errServerDown)
3030
}
3131
}
3232
}

loadbalancer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package loadbalancer
22

33
import (
44
"errors"
5-
"io"
65
"sync"
76
"time"
87
)
@@ -25,15 +24,14 @@ type EventHandler func(eventType int, server *Server)
2524
// -----------------------------------------------------------------------------
2625

2726
const (
28-
ServerUpEvent int = iota + 1
27+
ServerUpEvent int = iota + 1
2928
ServerDownEvent
3029
)
3130

3231
// -----------------------------------------------------------------------------
3332

3433
// Create creates a new load balancer manager
3534
func Create() *LoadBalancer {
36-
io.ErrClosedPipe = nil
3735
lb := LoadBalancer{
3836
mtx: sync.Mutex{},
3937
primaryGroup: ServerGroup{

0 commit comments

Comments
 (0)