Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Gopherjs runtime on frontend - inspired by gopherjs playground #76

Open
@naorzr

Description

@naorzr

Hello!

I've been experimenting these past 2 weeks on my spare time, trying to expose arunCode 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

runCode(`package mainimport ("fmt""syscall/js")func main() {fmt.Println("Hello, playground")js.Global().Call("alert", "Hello, JavaScript")js.Global().Get("console").Call("log", "Hello, JS console")}`)

I end up getting

$mapIndex is not defined

this error originates fromfmt.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 herehttps://github.com/naorzr/gopherjs-runtime/blob/master/playground/main.go
and it can be run and played with by running theindex.html from this repo
https://github.com/naorzr/gopherjs-runtime/tree/master/playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp