Fix random selector (#41)

* Fix a bug: when only have one upstream, random selector will panic

Signed-off-by: Sherlock Holo <sherlockya@gmail.com>
This commit is contained in:
Sherlock Holo authored and Star Brilliant committed 2019-03-24 09:13:14 +08:00
1 parent 475894baaa
commit 17e5848178
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ func (rs *RandomSelector) Add(url string, upstreamType UpstreamType) (err error)
}
func (rs *RandomSelector) Get() *Upstream {
return rs.upstreams[rand.Intn(len(rs.upstreams)-1)]
return rs.upstreams[rand.Intn(len(rs.upstreams))]
}
func (rs *RandomSelector) StartEvaluate() {}