GoogleCloudPlatform / go-endpoints

Cloud Endpoints for Go
https://go-endpoints.appspot.com
Apache License 2.0
255 stars 56 forks source link

2 errors on Windows 7 with "goapp serve helloworld/" #113

Closed IndianGuru closed 8 years ago

IndianGuru commented 8 years ago

G:\go_projects\go\src\github.com\SatishTalim>goapp serve helloworld/ INFO 2015-09-18 14:11:48,148 devappserver2.py:763] Skipping SDK update check . WARNING 2015-09-18 14:11:48,434 simple_search_stub.py:1126] Could not read sear ch indexes from c:\windows\temp\appengine.hello-world\search_indexes INFO 2015-09-18 14:11:48,477 api_server.py:205] Starting API server at: http ://localhost:59602 INFO 2015-09-18 14:11:48,487 dispatcher.py:197] Starting module "default" ru nning at: http://localhost:8080 INFO 2015-09-18 14:11:48,493 admin_server.py:118] Starting admin server at: http://localhost:8000 ERROR 2015-09-18 14:11:52,490 http_runtime.py:380] bad runtime process port [ ''] 2015/09/18 14:11:52 Register service: endpoints: "GreetingService" has no export ed methods of suitable type

gmlewis commented 8 years ago

Did you modify any files from samples/helloworld? What do you get when you type goapp version?

IndianGuru commented 8 years ago

No. I have not modified any of the files. My goapp version is go version go1.4.2 (appengine-1.9.26) windows/386

gmlewis commented 8 years ago

I just ran the example on my Windows box using windows/amd64, and it worked:

C:\Users\gmlewis\go\src\github.com\GoogleCloudPlatform\go-endpoints\samples\helloworld>d:\Downloads\go_appengine\goapp serve
INFO     2015-09-19 07:15:40,085 devappserver2.py:763] Skipping SDK update check.
WARNING  2015-09-19 07:15:40,266 simple_search_stub.py:1126] Could not read search indexes from d:\tmp\appengine.hello-world\search_indexes
INFO     2015-09-19 07:15:40,309 api_server.py:205] Starting API server at: http://localhost:54890
INFO     2015-09-19 07:15:40,318 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO     2015-09-19 07:15:40,328 admin_server.py:118] Starting admin server at: http://localhost:8000
INFO     2015-09-19 07:15:47,104 module.py:809] default: "GET / HTTP/1.1" 200 1333

and in another window:

$ bat localhost:8080
GET / HTTP/1.1
Host: localhost:8080
Accept: application/json
Accept-Encoding: gzip, deflate
User-Agent: bat/0.1.0

HTTP/1.1 200 OK
Server : Development/2.0
Date : Sat, 19 Sep 2015 14:15:47 GMT
Content-Length : 1333
Content-Type : text/html
Etag : "LTUwNDg4ODY2MA=="
Expires : Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control : no-cache

<!doctype html>
...

So it looks like either this is a windows/386 issue or something is not right on your system. I'll now try windows/386.

gmlewis commented 8 years ago

I just tested the windows/386 version, and it worked for me too, so I think something may be wrong with your installation or with your Windows box. Can you please try re-installing and/or try another Windows box?

C:\Users\gmlewis\go\src\github.com\GoogleCloudPlatform\go-endpoints\samples\helloworld>d:\Downloads\go_appengine\goapp version
go version go1.4.2 (appengine-1.9.26) windows/386

C:\Users\gmlewis\go\src\github.com\GoogleCloudPlatform\go-endpoints\samples\helloworld>d:\Downloads\go_appengine\goapp serve
INFO     2015-09-19 07:23:43,361 devappserver2.py:763] Skipping SDK update check.
INFO     2015-09-19 07:23:43,864 api_server.py:205] Starting API server at: http://localhost:54955
INFO     2015-09-19 07:23:43,872 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO     2015-09-19 07:23:43,882 admin_server.py:118] Starting admin server at: http://localhost:8000
INFO     2015-09-19 07:23:49,349 module.py:809] default: "GET / HTTP/1.1" 200 1333
IndianGuru commented 8 years ago

I will install everything and try again. Thanks.

IndianGuru commented 8 years ago

I re-installed everything on my Windows 7 32-bit box (I have been using Go on this box since 2013 and have never ever faced any problems).

I still get the same 2 errors.

Here's my configuration:

GOARCH=386 GOOS=windows GOPATH=G:\go_projects\go GOROOT=G:\go Path=G:\Python27;G:\go\bin;G:\go_projects\go\bin;G:\goappengine;G:\Google\Cloud SDK\google-cloud-sdk\bin;

Go Workspace:

clipboard01

Versions: Go - go version go1.5.1 windows/386 Python - 2.7.8 goapp - go version go1.4.2 (appengine-1.9.26) windows/386

As suggested by Jason Buberel:

Google Cloud SDK 0.9.78

bq 2.0.18 bq-win 2.0.18 core 2015.09.11 core-win 2015.08.10 gcloud 2015.09.11 gsutil 4.15 gsutil-win 4.13 windows-ssh-tools 2015.06.02

Unluckily, I don't have another Windows box and can't reinstall Windows on the existing one.

I am stuck, I guess :)

IndianGuru commented 8 years ago

I just re-solved the issue!

The error "panic: endpoints: "GreetingService" has no exported methods of suitable type" made me look at the code of service.go for 3 days - https://github.com/GoogleCloudPlatform/go-endpoints/blob/master/endpoints/service.go

I had already installed endpoints in April of this year. So was the problem being created since I had an earlier version of service.go?

It made sense to update the same.

The documentation says:

Add “-u” param to get an updated version, i.e.

go get -u github.com/GoogleCloudPlatform/go-endpoints/endpoints Now, you’ll see a couple errors, which is OK, don’t worry!

That's it! The problem got resolved.

Does golang have something that keeps all packages/libraries up-to-date?

gmlewis commented 8 years ago

I'm glad you found the problem. There are a number of 3rd-party vendoring solutions, but I don't know of anything that updates all your packages. That actually sounds like a potentially dangerous operation anyway.

broady commented 8 years ago

go get -u ... should update all of your packages :)

IndianGuru commented 8 years ago

The following is useful too.

An app that displays updates for the Go packages in your GOPATH.

aneshas commented 8 years ago
package posts

import (
    "log"

    "appengine"
    "appengine/datastore"

    "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
)

type Post struct {
    UID      string
    Text     string
    Username string
    Avatar   string
    Favorite bool
}

type Posts struct {
    Posts []Post
}

type PostAPI struct{}

func init() {
    _, err := endpoints.RegisterService(&PostAPI{}, "posts", "v1", "Posts API", true)
    if err != nil {
        log.Fatalf("Error: %v", err)
    }
    endpoints.HandleHTTP()
}

func (p *PostAPI) List(c appengine.Context) (*Posts, error) {
    var posts []Post

    _, err := datastore.NewQuery("Post").GetAll(c, &posts)
    if err != nil {
        return nil, err
    }

    return &Posts{posts}, nil
}

Getting the same error on linux machine, driving me crazy, I'm running go 1.5, goapp version is go version go1.4.2 (appengine-1.9.25) linux/amd64

Tried -u option when getting endpoints package, even tried deleting them manually, and still the same error. Running out of options...

aneshas commented 8 years ago

and if I change func (p *PostAPI) List(c appengine.Context) (*Posts, error) to func (p *PostAPI) List(c context.Context) (*Posts, error) - the line datastore.NewQuery("Post").GetAll(c, &posts) throws:

/tmp/tmpiQTn0Tappengine-go-bin/posts.go:40: cannot use c (type context.Context) as type "appengine".Context in argument to "appengine/datastore".NewQuery("Post").GetAll:
        context.Context does not implement "appengine".Context (missing Call method)

I am really not sure which Conext to use, the one from appengine package, the one from golang.org/x/net/context, I've even seen endpoints.Context which does not exist currently, endpoints documentation is really inconsistent regarding the Context usage.

aneshas commented 8 years ago

Got it working by using google.golang.org/appengine/datastore with context.Context instead of appengine/datastore but not sure what is the difference ?