math/rand => math/rand/v2
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||
"google.golang.org/grpc"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -51,7 +51,7 @@ func LookupFileId(masterFn GetMasterFn, grpcDialOption grpc.DialOption, fileId s
|
||||
if len(lookup.Locations) == 0 {
|
||||
return "", jwt, errors.New("File Not Found")
|
||||
}
|
||||
return "http://" + lookup.Locations[rand.Intn(len(lookup.Locations))].Url + "/" + fileId, lookup.Jwt, nil
|
||||
return "http://" + lookup.Locations[rand.IntN(len(lookup.Locations))].Url + "/" + fileId, lookup.Jwt, nil
|
||||
}
|
||||
|
||||
func LookupVolumeId(masterFn GetMasterFn, grpcDialOption grpc.DialOption, vid string) (*LookupResult, error) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||
"io"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"mime"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -236,7 +236,7 @@ func genFileUrl(ret *AssignResult, id string, usePublicUrl bool) string {
|
||||
fileUrl = "http://" + ret.PublicUrl + "/" + id
|
||||
}
|
||||
for _, replica := range ret.Replicas {
|
||||
if rand.Intn(len(ret.Replicas)+1) == 0 {
|
||||
if rand.IntN(len(ret.Replicas)+1) == 0 {
|
||||
fileUrl = "http://" + replica.Url + "/" + id
|
||||
if usePublicUrl {
|
||||
fileUrl = "http://" + replica.PublicUrl + "/" + id
|
||||
|
||||
Reference in New Issue
Block a user