英文:
Google App Engine: Can't import Go packages
问题
我正在尝试使用Google App Engine的“hello world”示例,可以在这里找到。我正在使用Go语言,并且按照上述教程中给出的步骤进行操作。此外,我已经使用这里的安装程序安装了Go。我正在运行Windows 7 x64。
当我使用命令提示符运行示例应用程序时:
dev_appserver.py c:\@Code\Go\myapp
我得到以下响应:
INFO 2013-10-17 11:17:00,497 sdk_update_checker.py:245] 检查更新
SDK。
INFO 2013-10-17 11:17:02,756 sdk_update_checker.py:273] SDK已经是最新的
。
WARNING 2013-10-17 11:17:02,815 api_server.py:332] 无法初始化图像
API;可能缺少Python的“PIL”模块。
INFO 2013-10-17 11:17:02,828 api_server.py:139] 在此处启动API服务器:http
://localhost:53563
INFO 2013-10-17 11:17:02,834 dispatcher.py:171] 启动模块“default”运行在:http://localhost:8080
INFO 2013-10-17 11:17:02,838 admin_server.py:117] 启动管理服务器在:
http://localhost:8000
ERROR 2013-10-17 11:17:02,905 go_runtime.py:165] 无法构建Go应用
程序:c:\@Code\Go\myapp\hello\hello.go:4: 找不到导入:“fmt”
2013/10/17 11:17:02 go-app-builder: 构建时间:1├ù6g(总共16毫秒),0├ùgopack
(总共0),0├ù6l(总共0)
2013/10/17 11:17:02 go-app-builder: 运行6g.exe失败:退出状态1
(执行的命令:C:\go_appengine\goroot\bin\go-app-builder.exe -app_base c:\@C
ode\Go\myapp -arch 6 -binary_name _go_app -dynamic -extra_imports appengine_inte
rnal/init -goroot C:\go_appengine\goroot -gcflags -I=C:\go_appengine\goroot\pkg\
windows_amd64_appengine -ldflags -L=C:\go_appengine\goroot\pkg\windows_amd64_app
engine -nobuild_files ^^$ -unsafe -work_dir c:\users\dennyc~1.sun\appdata\local\
temp\tmpr5dxl2appengine-go-bin hello\hello.go)
上面的所有路径似乎都是有效的(尽管我承认我不知道它们的含义),除了最后一个“temp”文件夹。如您在示例应用中所见,fmt
是第一个导入。如果我交换这两个导入,我会得到相同的错误,但是针对net/http
。
我知道Go已经正确安装,因为我可以直接从Go运行以下测试Go应用程序:
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
...。
我已经尝试过调整各种环境变量,但没有成功。但是,鉴于测试Go应用程序可以正常工作,我认为这与App Engine有关。
英文:
I'm attempting the Google App Engine "hello world" example found here. I'm using the Go language, and following exactly the steps given in the above-mentioned tutorial. Additionally, I've installed Go using the installer here. I'm running Windows 7 x64.
When I run the sample app, using the command prompt:
dev_appserver.py c:\@Code\Go\myapp
I get the following response:
INFO 2013-10-17 11:17:00,497 sdk_update_checker.py:245] Checking for updates
to the SDK.
INFO 2013-10-17 11:17:02,756 sdk_update_checker.py:273] The SDK is up to dat
e.
WARNING 2013-10-17 11:17:02,815 api_server.py:332] Could not initialize images
API; you are likely missing the Python "PIL" module.
INFO 2013-10-17 11:17:02,828 api_server.py:139] Starting API server at: http
://localhost:53563
INFO 2013-10-17 11:17:02,834 dispatcher.py:171] Starting module "default" ru
nning at: http://localhost:8080
INFO 2013-10-17 11:17:02,838 admin_server.py:117] Starting admin server at:
http://localhost:8000
ERROR 2013-10-17 11:17:02,905 go_runtime.py:165] Failed to build Go applicati
on: c:\@Code\Go\myapp\hello\hello.go:4: can't find import: "fmt"
2013/10/17 11:17:02 go-app-builder: build timing: 1×6g (16ms total), 0×gopack
(0 total), 0×6l (0 total)
2013/10/17 11:17:02 go-app-builder: failed running 6g.exe: exit status 1
(Executed command: C:\go_appengine\goroot\bin\go-app-builder.exe -app_base c:\@C
ode\Go\myapp -arch 6 -binary_name _go_app -dynamic -extra_imports appengine_inte
rnal/init -goroot C:\go_appengine\goroot -gcflags -I=C:\go_appengine\goroot\pkg\
windows_amd64_appengine -ldflags -L=C:\go_appengine\goroot\pkg\windows_amd64_app
engine -nobuild_files ^^$ -unsafe -work_dir c:\users\dennyc~1.sun\appdata\local\
temp\tmpr5dxl2appengine-go-bin hello\hello.go)
All of the paths above seem to be valid (although admittedly I don't know what any of them mean) with the exception of the last temp
folder. As you can see in the sample app, fmt
is the first import. If I swap the two imports, I get the same error but for net/http
.
I know Go is properly installed because I can run the following test Go app:
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
...directly from Go.
I've tried messing with all of the various Environment Variables at no avail. But, seeing as to how the test Go app will work, I'm thinking this has something to do with the App Engine.
答案1
得分: 3
最近发布的Windows SDK(1.8.6)中存在一个错误。新版本(1.8.6.1)已经发布,修复了该错误。请尝试下载该版本。
https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go
英文:
There was a bug in the recently released windows SDK (1.8.6). A newer version has just been released which fixes that bug (1.8.6.1). Try downloading that version instead.
https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论