Adam Crossland
Adam Crossland

Reputation: 14213

AppEngine/Go app won't compile. What did I miss?

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.

Upvotes: 2

Views: 878

Answers (2)

Chris Bunch
Chris Bunch

Reputation: 89823

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)
}

Upvotes: 9

Nick Johnson
Nick Johnson

Reputation: 101149

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?

Upvotes: 0

Related Questions