Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Use python function as go function #14

Open
teodor-pripoae opened this issue Jan 4, 2017 · 2 comments
Open

Use python function as go function #14

teodor-pripoae opened this issue Jan 4, 2017 · 2 comments

Comments

@teodor-pripoae
Copy link

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
@trotterdylan
Copy link
Contributor

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.

@S-YOU
Copy link
Contributor

S-YOU commented Jan 5, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants