Merge pull request #8556 from gyuho/go-tip

client: fix TestHTTPClusterClientSyncUnpinEndpoint
This commit is contained in:
Gyu-Ho Lee 2017-09-22 13:33:34 +09:00 committed by GitHub
commit cbddcfd9ad

View File

@ -670,8 +670,15 @@ func (r *redirectedHTTPAction) HTTPRequest(ep url.URL) *http.Request {
}
func shuffleEndpoints(r *rand.Rand, eps []url.URL) []url.URL {
p := r.Perm(len(eps))
neps := make([]url.URL, len(eps))
// copied from Go 1.9<= rand.Rand.Perm
n := len(eps)
p := make([]int, n)
for i := 0; i < n; i++ {
j := r.Intn(i + 1)
p[i] = p[j]
p[j] = i
}
neps := make([]url.URL, n)
for i, k := range p {
neps[i] = eps[k]
}