duanbu9345 2011-08-23 23:51
浏览 40
已采纳

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

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.

  • 写回答

2条回答 默认 最新

  • dqaq59269 2011-08-24 03:20
    关注

    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)
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型