如何从云端访问其他 GCP 服务 运行
How to access other GCP services from Cloud Run
我正在尝试从 Cloud 运行 中的 Go 网站 运行 访问 Google Cloud 运行,但是当我尝试访问时,程序一直处于恐慌状态创建视觉客户端:
client, err := vision.NewImageAnnotatorClient(context.Background(), nil)
恐慌:
runtime error: invalid memory address or nil pointer dereference goroutine
我假设因为它是 运行 在 GCP 中并且云 运行 服务被分配了一个 IAM 帐户有权访问 Vision API 它只能访问它类似于没有密钥的 Cloud Functions,我在这里缺少什么才能正常工作吗?
代码片段很短,所以它并没有真正给我们足够的信息来说明它为什么会失败。
查看文档,我不知道您需要 nil
作为 vision.NewImageAnnotatorClient
的第二个参数。
尝试只传递 context.Background()
,看看是否能解决您的问题。
我正在尝试从 Cloud 运行 中的 Go 网站 运行 访问 Google Cloud 运行,但是当我尝试访问时,程序一直处于恐慌状态创建视觉客户端:
client, err := vision.NewImageAnnotatorClient(context.Background(), nil)
恐慌:
runtime error: invalid memory address or nil pointer dereference goroutine
我假设因为它是 运行 在 GCP 中并且云 运行 服务被分配了一个 IAM 帐户有权访问 Vision API 它只能访问它类似于没有密钥的 Cloud Functions,我在这里缺少什么才能正常工作吗?
代码片段很短,所以它并没有真正给我们足够的信息来说明它为什么会失败。
查看文档,我不知道您需要 nil
作为 vision.NewImageAnnotatorClient
的第二个参数。
尝试只传递 context.Background()
,看看是否能解决您的问题。