Go Google Cloud Vision API. Likelihood_POSSIBLE not declared by package vision

huangapple go评论81阅读模式
英文:

Go Google Cloud Vision API. Likelihood_POSSIBLE not declared by package vision

问题

我正在使用Go语言的Cloud Vision API。我想使用DetectSafeSearch函数。它返回*vision.SafeSearchAnnotation类型。

所以,我写了下面的代码。

if prop.Adult == vision.Likelihood_POSSIBLE { ... }

但是我得到了一个编译错误,错误信息是Likelihood_POSSIBLE not declared by package vision。但是在vision包中似乎导出了Likelihood_POSSIBLE

为什么会出现这个错误?

以及如何正确处理prop.Adult

英文:

I am using cloud vision api for the Go language.
I want to use DetectSafeSearch.
It returns *vision.SafeSearchAnnotation.

So, I wrote a code below.

if prop.Adult == vision.Likelihood_POSSIBLE { ... }

But I got a compile error Likelihood_POSSIBLE not declared by package vision.
But it seems Likelihood_POSSIBLE is exported in vision package.

Why did I got this error ?

And what is the proper way to handle prop.Adult ?

答案1

得分: 2

导入 visionpb 包 "google.golang.org/genproto/googleapis/cloud/vision/v1"。

英文:

import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1"

huangapple
  • 本文由 发表于 2021年9月5日 16:07:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/69061611.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定