我无法使用google.golang.org/appengine模块将Go模块部署到App Engine。

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

I can't deploy a Go module to App Engine using the google.golang.org/appengine modules

问题

根据我所读到的最新资料以及某些API的文档(例如,Go Datastore API),我应该使用google.golang.org/appengine等而不是旧的appengine/...路径。然而,当我尝试使用gcloud preview app deploy部署时,出现以下错误:

部署包含无法编译的文件:编译失败:

2016/01/14 14:32:43 go-app-builder: build timing: 2×6g(总共113毫秒),0×6l(总共0)
2016/01/14 14:32:43 go-app-builder: 运行6g失败:退出状态1

server/alexa.go:10: 找不到导入包:“golang.org/x/net/context”

golang.org/x/net/context包据说替代了旧的appengine/context包,但在部署服务器的GOROOT中似乎无法找到它。

我尝试将所有依赖项及其依赖项都包含在我的软件包存储库中,但这只导致了这个晦涩的错误(它抱怨的目录实际上是存在的):

部署包含无法编译的文件:编译失败:

2016/01/14 14:27:04 go-app-builder: build timing: 18×6g(总共1.819秒),0×6l(总共0)
2016/01/14 14:27:04 go-app-builder: 运行6g失败:退出状态1

github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go:27: 找不到导入包:“github.com/golang/protobuf/protoc-gen-go/testdata/multi”

我是否误解了文档,只能使用旧的包?

英文:

From the latest material I can read, and also based on documentation on certain APIs (for example, the Go Datastore API), I'm supposed to use google.golang.org/appengine etc. instead of the old appengine/... paths. However, when I try to deploy using gcloud preview app deploy, I get the following error:

> Deployment contains files that cannot be compiled: Compile failed:
>
> 2016/01/14 14:32:43 go-app-builder: build timing: 2×6g (113ms total), 0×6l (0 total)
> 2016/01/14 14:32:43 go-app-builder: failed running 6g: exit status 1
>
> server/alexa.go:10: can't find import: "golang.org/x/net/context"

The golang.org/x/net/context package supposedly replaces the old appengine/context one, but it doesn't appear to be available in the deployment server's GOROOT.

I tried including all the dependencies and their dependencies in my package repo but that only lead me to this obscure error (the directory it's complaining about actually exists):

> Deployment contains files that cannot be compiled: Compile failed:
>
> 2016/01/14 14:27:04 go-app-builder: build timing: 18×6g (1.819s total), 0×6l (0 total)
> 2016/01/14 14:27:04 go-app-builder: failed running 6g: exit status 1
>
> github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.pb.go:27: can't find import: "github.com/golang/protobuf/protoc-gen-go/testdata/multi"

Have I misunderstood the documentation and am only supposed to use the old packages?

答案1

得分: 2

你需要执行go get golang.org/x/net/context命令,将该包保存在你的go src目录中。不过,在使用App Engine时,这是不必要的。这些库可以被导入和使用,但它们主要用于在App Engine之外运行的应用程序,例如容器引擎或计算引擎。它们基本上是针对这些服务的RESTful API进行了封装。如果你决定直接使用Google Cloud Storage,你将需要这些库,因为App Engine希望你使用Blobstore。希望这可以帮到你。

英文:

You need to do a go get golang.org/x/net/context to save that package in your go src directory. Though, when working with App Engine it is not necessary. Those libraries can be imported and used, but they mostly focused on applications run outside of App Engine, i.e. Container Engine or Compute Engine. They essentially hook into the RESTful APIs Google cooked up for those services. If you decide to work directly with Google Cloud Storage you would need those libraries since App Engine expects you to use Blobstore instead. Hope this helps.

答案2

得分: 1

如果你正在使用gosdk,只需在与你的.go文件相同的目录中运行goapp get,它将下载并安装依赖项到你的gosdk安装中。然后再次部署应用程序,应该可以编译无误。

当它工作时,没有提示,文件将被下载到gosdk\gopath\src目录下。

完成后会有一个可以忽略的警告信息:

go install: no install location for directory
C:\your_current_directory outside GOPATH
For more details see: go help gopath

英文:

If you are using gosdk, just run goapp get in the same directory as your .go file and it will download and install the dependencies to your gosdk installation. You then deploy the app again and it should compile without problem.

When it's working there's no prompt and files will be downloaded to gosdk\gopath\src

After fininshing there will be a warning message which can be ignored:

> go install: no install location for directory
> C:\your_current_directory outside GOPATH
> For more details see: go help gopath

答案3

得分: 0

记录一下,这个问题现在已经通过gcloud版本142修复了。
现在可以使用gcloud beta app deploy --project <project> app.yaml来部署。使用gcloud components update来升级命令行工具。

  • 这是一个示例项目,可以查看它的工作情况:https://github.com/aubm/my-test-app
  • 这是Travis的构建日志:https://travis-ci.org/aubm/my-test-app/builds/198057096
英文:

For the record, this issue is now fixed with gcloud version 142.
One should now be able to deploy using gcloud beta app deploy --project &lt;project&gt; app.yaml. Use gcloud components update to upgrade the command line.

huangapple
  • 本文由 发表于 2016年1月15日 09:36:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/34802974.html
匿名

发表评论

匿名网友

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

确定