【发布时间】:2017-09-19 08:25:10
【问题描述】:
我正在编译一个 GO 应用,我想上传并在 Google Cloud Platform 上运行。我正在导入appengine/datastore 包,并且遇到了包供应问题。因为我想提供稳定的构建,所以我希望在我的源代码树中提供尽可能多的依赖项,但是当我提供 appengine/datastore 时,我遇到了运行 gcloud app deploy 的问题:
OperationError:错误响应:[9] 部署包含无法编译的文件:编译失败: 2017/09/19 01:07:31 go-app-builder:解析输入失败:包“vendor/google.golang.org/appengine/search”无法导入内部包“google.golang.org/appengine/internal/search” "
ERROR: (gcloud.app.deploy) Error Response: [9] Deployment contains files that cannot be compiled: Compile failed:
2017/09/19 01:07:31 go-app-builder: Failed parsing input: package "vendor/google.golang.org/appengine/search" cannot import internal package "google.golang.org/appengine/internal/search"
我可以正常运行dev_appserver.py脚本,应用程序在本地运行流畅,go test成功编译运行所有模块测试。
如果我尝试删除任何 appengine 包的供应商,而是使用 go get 在版本控制之外安装它们,dev_appserver.py 将不再运行,并抱怨重复的包:
rm -rf ../vendor/google.golang.org/appengine
go get google.golang.org/appengine
dev_appserver.py app.yaml
[....]
2017/09/19 10:20:10 go-app-builder: Failed parsing input: package "golang.org/x/net/context" is imported from multiple locations: "/home/peter/src/myproject/go/src/myproject/vendor/golang.org/x/net/context" and "/home/peter/src/myproject/go/src/golang.org/x/net/context"
而gcloud app deploy 却抱怨根本找不到包:
[...]
File upload done.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Deployment contains files that cannot be compiled: Compile failed:
Compile failed:
2017/09/19 01:22:13 go-app-builder: build timing: 7×compile (1.749s total), 0×link (0s total)
2017/09/19 01:22:13 go-app-builder: failed running compile: exit status 2
myproject/vendor/golang.org/x/text/unicode/norm/normalize.go:15: can't find import: "golang.org/x/text/transform"
$ find .. -name transform
../vendor/golang.org/x/text/transform
编辑:解决方法:我发现我可以通过将供应商目录(github.com 和 golang.org)符号链接到应用程序目录(ln -s ../vendor/* .),并手动下载 appengine 包(go get google.golang.org/appengine)。但是,我需要删除符号链接才能运行dev_appserver.py,所以这不是最佳的。
【问题讨论】:
标签: google-app-engine go gcloud