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

playground: compile gofmt, golint to wasm to lint/format code from the browser #32331

Open
paulvollmer opened this issue May 30, 2019 · 3 comments

Comments

@paulvollmer
Copy link

commented May 30, 2019

What did you do?

i played a bit with GOARCH=wasm and it's great. after that i thought "what if i compile go to wasm". writing go code at the browser and compile it there. sounds crazy...
Then i thought it could be helpful to compile gofmt or golint to wasm to reduce the network traffic at play.golang.org or embed it directly into atom or vscode.

i tried to compile but io and os.stdin/stdout packages cannot be used with the wasm compiler.

i really like the idea and it's possible to refactor gofmt to compile to wasm. my question is if i start refactoring gofmt to build a proof of concept this will become a merge candidate?

if not i'll go and do the proof of concept at a new repo and just copy some pieces of gofmt to build the wasm version.

the first test parsing go code with the go/ast packages worked well and you can see the result here: yuroyoro/goast-viewer#11

thanks in advance

@agnivade

This comment has been minimized.

Copy link
Member

commented May 30, 2019

Compiling gofmt or go to wasm is indeed very much possible. But play.golang.org also needs to compile the code, which is not possible in the browser yet. See #15108 (comment).

@julieqiu julieqiu changed the title Experimental: compile gofmt, golint to wasm to lint/format code from the browser playground: compile gofmt, golint to wasm to lint/format code from the browser May 30, 2019

@chfanghr

This comment has been minimized.

Copy link

commented May 31, 2019

@ccbrown

This comment has been minimized.

Copy link

commented Jul 5, 2019

My playground here now does this: https://ccbrown.github.io/go-web-gc/

I don't really see any real reason why any refactoring or code changes would be needed for use in the playground or plugins.

Shipping the gofmt WASM (~1MB) with the playground would probably increase network traffic for your average user though, and as for embedding into Atom or other IDEs... why not just use the host's Go binaries? (I'm assuming not many people write Go without having Go installed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.