Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use python function as go function #13

Open
alanjds opened this issue Aug 21, 2018 · 2 comments
Open

Use python function as go function #13

alanjds opened this issue Aug 21, 2018 · 2 comments
Labels
imported Imported from google/grumpy

Comments

@alanjds
Copy link

alanjds commented Aug 21, 2018

google#14 opened by @teodor-pripoae on 4 Jan 2017

I'm trying to implement a simple HTTP server, but it seems I can't send a python function as a go function to HandleFunc.

from __go__.net.http import ListenAndServe
from __go__.githubcom.gorilla.mux import NewRouter
from __go__.fmt import Fprintf

def HomeHandler(w, r):
    Fprintf(w, "Hello world")

r = NewRouter()
r.HandleFunc("/", HomeHandler)
ListenAndServe(":8000", r)

I'm receiving this error:

$ cat web.py | make run
TypeError: cannot convert grumpy.Object to func(http.ResponseWriter, *http.Request)
exit status 1
make: *** [run] Error 1
@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by trotterdylan
Wednesday Jan 04, 2017 at 21:08 GMT


Yeah, this used to work but I think it got removed as part of some other refactoring. I'll spend some time getting it working again.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by S-YOU
Thursday Jan 05, 2017 at 07:42 GMT


I think the real issue is how to convert something(w, r) from python to func(http.ResponseWriter, *http.Request), you might need type annotations like python 3.6 does.

@alanjds alanjds added the imported Imported from google/grumpy label Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported Imported from google/grumpy
Projects
None yet
Development

No branches or pull requests

1 participant