Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace deprecated rand.Seed usage with local random generator #788

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s *GreeterProvider) SayHelloStream(svr pb.Greeter_SayHelloStreamServer) er
}

func (s *GreeterProvider) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.User, error) {
fmt.Printf("Dubbo3 GreeterProvider get user name = %s\n" + in.Name)
fmt.Printf("Dubbo3 GreeterProvider get user name = %s\n", in.Name)
return &pb.User{Name: "Hello " + in.Name, Id: "12345", Age: 21}, nil
}

Expand Down
5 changes: 3 additions & 2 deletions metrics/go-server/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ type GreetTripleServer struct {

func (srv *GreetTripleServer) Greet(_ context.Context, req *greet.GreetRequest) (*greet.GreetResponse, error) {
resp := &greet.GreetResponse{Greeting: req.Name}
rand.Seed(time.Now().UnixNano())
if rand.Intn(101) > 99 { // mock error here
source := rand.NewSource(time.Now().UnixNano())
r := rand.New(source)
if r.Intn(101) > 99 { // mock error here
return nil, errors.New("random error")
}
time.Sleep(10 * time.Millisecond) // mock business delay
Expand Down
Loading