英文:
grpc.WithInsecure is deprecated: use insecure.NewCredentials() instead
问题
嘿,我正在尝试使用Go和Grpc创建一个小型测试客户端。
opts := insecure.NewCredentials()
cc, err := grpc.Dial("localhost:9950", opts)
if err != nil {
    log.Fatal(err)
}
insecure.NewCredentials()函数调用会给出一个警告:
grpc.WithInsecure已被弃用:请使用insecure.NewCredentials()代替。
我不确定如何使用这个新的函数调用,有没有示例可以参考?谢谢。
英文:
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
答案1
得分: 65
insecure.NewCredentials 函数返回一个 credentials.TransportCredentials 的实现。
你可以将其作为 DialOption 使用,使用 grpc.WithTransportCredentials:
grpc.Dial(":9950", grpc.WithTransportCredentials(insecure.NewCredentials()))
英文:
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()))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论