英文:
AppEngine/Go app won't compile. What did I miss?
问题
我正在尝试测试一个AppEngine/Go应用程序。我启动dev_appserver.py
并开始提供应用程序,但是当我在浏览器中输入localhost:8080
时,我得到以下错误信息:
编译错误:
/home/adam/foobar/server/app/server.go:5: 找不到导入:appengine/users
2011/08/23 19:45:34 go-app-builder: 构建应用程序失败:运行8g失败:退出状态1
我感觉我需要做一些事情,以使AppEngine特定的库在GO期望它们存在的位置可用,但是我真的不想在AppEngine/Go SDK压缩包中的所有内容上运行goinstall
,对吗?我似乎错过了一个安装步骤,但是就我而言,我无法找到明智和正确的做法。
我使用的是Ubuntu,如果这有关系的话。
英文:
I am trying to test an AppEngine/Go application. I start dev_appserver.py
and it begins serving the application, but when I go to localhost:8080
in my browser, I get:
Compile error:
/home/adam/foobar/server/app/server.go:5: can't find import: appengine/users
2011/08/23 19:45:34 go-app-builder: Failed building app: failed running 8g: exit status 1
I feel as though I need to do something to make the AppEngine-specific libraries available where GO expects them to be, but I don't really want to run goinstall
on everything that comes in the AppEngine/Go SDK zip, do I? I seem to have missed an installation step, but for the life of me, I can't figure the sane and right thing to do.
I am on Ubuntu, if that matters.
答案1
得分: 9
用户API不是appengine/users
,而是appengine/user
。从App Engine页面的示例中可以看到:
import (
"appengine"
"appengine/user"
)
func welcome(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
u := user.Current(c)
if u == nil {
url := u.LoginURL(c, "/")
fmt.Fprintf(w, `<a href="%s">登录或注册</a>`, url)
return
}
url := user.LogoutURL(c, "/")
fmt.Fprintf(w, `欢迎,%s!(<a href="%s">退出</a>)`, u, url)
}
英文:
The Users API isn't appengine/users
- it's appengine/user
. From the example on the App Engine page:
import (
"appengine"
"appengine/user"
)
func welcome(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
u := user.Current(c)
if u == nil {
url := u.LoginURL(c, "/")
fmt.Fprintf(w, `<a href="%s">Sign in or register</a>`, url)
return
}
url := user.LogoutURL(c, "/")
fmt.Fprintf(w, `Welcome, %s! (<a href="%s">sign out</a>)`, u, url)
}
答案2
得分: 0
你不需要自己编译代码 - 只需运行dev_appserver
,它会在代码更改时为您编译。您是否已经阅读了入门文档?
英文:
You don't have to compile the code yourself - just run the dev_appserver
and it will compile it for you whenever the code changes. Have you gone through the getting started docs?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论