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

paulvollmer opened this issue May 30, 2019 · 3 comments


Copy link

@paulvollmer paulvollmer 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 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

Copy link

@agnivade agnivade commented May 30, 2019

Compiling gofmt or go to wasm is indeed very much possible. But 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
Copy link

@chfanghr chfanghr commented May 31, 2019

Copy link

@ccbrown ccbrown commented Jul 5, 2019

My playground here now does this:

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
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.