AppEngine/Go 应用程序无法编译。我错过了什么?

发布于 2024-12-01 08:19:39 字数 489 浏览 1 评论 0原文

我正在尝试测试 AppEngine/Go 应用程序。我启动 dev_appserver.py 并开始为应用程序提供服务,但是当我在浏览器中访问 localhost:8080 时,我得到:

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

我觉得我需要做点什么使 AppEngine 特定的库在 GO 期望的位置可用,但我真的不想在 AppEngine/Go SDK zip 中的所有内容上运行 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

望她远 2024-12-08 08:19:39

Users 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">Sign in or register</a>`, url)
        return
    }
    url := user.LogoutURL(c, "/")
    fmt.Fprintf(w, `Welcome, %s! (<a href="%s">sign out</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)
}
嘿咻 2024-12-08 08:19:39

您不必自己编译代码 - 只需运行 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文