-
Notifications
You must be signed in to change notification settings - Fork 12
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
Gopherjs runtime on frontend - inspired by gopherjs playground #76
Comments
I haven't tried to run your code, but I see at least one significant misunderstanding, which is probably causing at least some of your issues. There aren't two phases per se. You provide the compiler with the main package and the So instead of running one attempt to compiler, collecting dependencies, loading them, and making the next attempt you should just load the package when the compiler asks for it, completing the whole thing in a single pass. |
Besides that, a couple of general tips:
|
if I get it right, do you suggest placing the |
Ok, so I spent some time looking at your code today, and there were two main issues:
On a more general note, part of the GopherJS philosophy is that you could try to write your code as you would with normal Go, as much as possible, and confine JS-aware parts to as few places as possible. That tends to yield a much more readable program. I did some refactoring of your code and you can find a working example here: nevkontakte@5408ff2#diff-6639521c1bb3cd1e0ee9891ede42f19a89aab52a1417124481590cf761dfe432 |
Hello!
I've been experimenting these past 2 weeks on my spare time, trying to expose a
runCode
global at the frontend, that will allow users to run arbitrary Go code, purely on the client side, it is heavily inspired by the gopher playground.I removed the UI parts, and made some modifications, but I seem to be hitting a roadblock,
when trying to use
I end up getting
this error originates from
fmt.Println
function only, other fmt functions I've tested work as expected.Also, I've noticed that in the original code, there's a loading phase first, and then a run, it seems necessary in my case too, (running the code seems to be doing the loading phase + running, which throws some errors, but running again, will just run the code without loading, and result with no console errors) I'm just not sure as to how to implement it.
the altered code can be found here https://github.com/naorzr/gopherjs-runtime/blob/master/playground/main.go
and it can be run and played with by running the
index.html
from this repohttps://github.com/naorzr/gopherjs-runtime/tree/master/playground
The text was updated successfully, but these errors were encountered: