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

Closed
paulvollmer opened this issue May 30, 2019 · 4 comments
Labels
arch-wasm WebAssembly issues FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@paulvollmer
Copy link

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

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
@julieqiu julieqiu added FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 30, 2019
@chfanghr
Copy link

chfanghr commented May 31, 2019 via email

@agnivade agnivade added the arch-wasm WebAssembly issues label Jul 5, 2019
@ccbrown
Copy link

ccbrown 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.)

@neelance
Copy link
Member

@ccbrown This is really nice work!

@paulvollmer It is a nice POC and it is fascinating to see that it works, but it is still much slower and less compatible than the current Go Playground. This is neither a bug nor a proper feature request, so I'll close this issue for now.

@golang golang locked and limited conversation to collaborators Oct 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly issues FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

7 participants