根据我可以阅读的最新 Material ,以及基于某些 API 的文档(例如,the Go Datastore API),我应该使用 google.golang.org/appengine
等。而不是旧的 appengine/...
路径。但是,当我尝试使用 gcloud preview app deploy 进行部署时,出现以下错误:
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"
golang.org/x/net/context
包应该取代了旧的 appengine/context
包,但它似乎在部署服务器的GOROOT
.
我尝试在我的包存储库中包含所有依赖项及其依赖项,但这只会导致我出现这个晦涩的错误(它提示的目录实际上存在):
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"
我是否误解了文档并且应该只使用旧包?
最佳答案
您需要执行 go get golang.org/x/net/context
以将该包保存在您的 go src 目录中。但是,在使用 App Engine 时没有必要。这些库可以导入和使用,但它们主要侧重于在 App Engine 之外运行的应用程序,即 Container Engine 或 Compute Engine。它们基本上连接到谷歌为这些服务设计的 RESTful API。如果您决定直接使用 Google Cloud Storage,您将需要这些库,因为 App Engine 希望您改用 Blobstore。希望这会有所帮助。
关于google-app-engine - 我无法使用 google.golang.org/appengine 模块将 Go 模块部署到 App Engine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34802974/