Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grpc.WithInsecure is deprecated: use insecure.NewCredentials() instead

Tags:

go

grpc

grpc-go

Hey I'm trying make a small test client with Go and Grpc,

opts := grpc.WithInsecure()
    cc, err := grpc.Dial("localhost:9950", opts)
    if err != nil {
        log.Fatal(err)
    }

The WithInsecure() function call gives a warning:

grpc.WithInsecure is deprecated: use insecure.NewCredentials() instead.

I'm not sure how to use this new function call is there an example somewhere? Thanks

like image 484
shwick Avatar asked Dec 30 '22 11:12

shwick


1 Answers

The function insecure.NewCredentials returns an implementation of credentials.TransportCredentials.

You can use it as a DialOption with grpc.WithTransportCredentials:

grpc.Dial(":9950", grpc.WithTransportCredentials(insecure.NewCredentials()))
like image 142
blackgreen Avatar answered Apr 27 '23 18:04

blackgreen