Go compiler running entirely in your browser

wasm-go-playground

This is the Go compiler ("gc") compiled for WASM, running in your browser! It can be used to run a simple playground, à la play.golang.org entirely in your browser!

You can try it out here: https://ccbrown.github.io/wasm-go-playground

⚠️ Important ⚠️

  • Safari works, but is unbearably slow. Chrome or Firefox for desktop is highly recommended.
  • Imports other than "runtime" are not supported. Making them work would be straightforward, but I'm not compelled to spend time on it right now since this probably has no practical uses.

Experimental Playgrounds

One potential use-case for this is making compiler changes easily and freely available for people to try out.

If you're interested in trying out the try proposal, you can do so here: https://ccbrown.github.io/wasm-go-playground/experimental/try-builtin/

If you're interested in trying out generics draft design, you can do so here: https://ccbrown.github.io/wasm-go-playground/experimental/generics/

Code

  • ./cmd – These are Go commands compiled for WASM. They were all produced by running commands such as GOOS=js GOARCH=wasm go build . from the Go source directories.
  • ./experimental – This directory contains experimental playgrounds, for testing out modified compilers.
  • ./prebuilt – These are prebuilt runtime WASM files. These were produced by copying them from Go's cache after compiling anything for WASM.
  • . – The top level directory contains all the static files for the in-browser Go playground. Most of the files are lightly modified copies of bits and pieces from play.golang.org. The most substantial work here is in index.html and wasm_exec.js as wasm_exec.js needed a virtual filesystem implementation.
Comments
  • generics maybe monad

    generics maybe monad

    Hi,

    I realize this is all very experimental and unstable, but I was playing around and wondering if this would work.

    type Maybe(type A) interface {
    	Map(type B)(func(A) B) Maybe(B)
    }
    
    type Nothing(type A) struct {}
    
    func (m Nothing(A)) Map(type B)(f func(A) B) Maybe(B) {
    	return Nothing(B){}
    }
    
    type Just(type A) struct {
    	v A
    }
    
    func (m Just(A)) Map(type B)(f func(A) B) Maybe(B) {
    	return Just(B){v: f(m.v)}
    }
    

    It doesn't compile, so am I missing something or does this just not work (yet)?

    On the other hand, this seems to work: https://ccbrown.github.io/wasm-go-playground/experimental/generics/#A4Qwxg1iDmCmAEBbEBLAdgKA2A9mgLgE7j7wDOR6chAFAIICU8A3hgJB3wDKla0NTCoSoYAvlnwBPYAgCyISQCNYNKTPichVWISbp8OgGbgErNvOA1DAVzRh6TRvHlKVjdj2F8B5XtDES0ggAcjj4ABZUqkEavl7UgkTWYKTM4hg2dvA0iPChEVGMTBZW8Jn2Tk4uyg4s7ISw+NaEaHlhkd6MaQEZtmDZufkd/EXcfj5afHVsDU0t8ABECz1qCABS1hTR6pp+OomEyansAG4aPeUD8BtboyWGZX21VQo1Tmazza03+A7MJwAuMo5AB0JwY4nSlxy102v1GniiByo00+80QYJBiO8DBWMQAaiAADbWBBCI7TM6TfxQvrZM6EkmwJjY/jIqYfRpfeAnMEXOnIdA+MwnECEeCtIZRRmk3FsABW8ABAF5YVsZcz/kCNVrFuFYESiTgFqJxGx2CAlaq0CD7k8GcTZfANSx4GjWjrATywQBqBYAbngAHccIQiQATE3wURy4BefBEtA0EBY8YMOXsRRW+Dy20gSzlGgOplMF3MN1c+aeoG8k5+wMhsOR0TR2PxxM0RSp+ICXGiIA===

    The initial implementation looks really nice though, I love the idea.

  • can't find import:

    can't find import: "runtime"

    Compiling a simple program:

    package main
    
    import "runtime"
    
    func main() {
    	println(runtime.Version())
    }
    

    fails with:

    main.go:3:8: can't find import: "runtime"
    

    The same program works fine in the original playground: https://play.golang.org/p/p4NGaPmEVqA

  • add sharing

    add sharing

    Adds sharing. In the spirit of doing things in the browser, sharing is also serverless. The code just gets encoded to the URL hash.

    https://ccbrown.github.io/wasm-go-playground/experimental/try-builtin/#A4Qwxg1iDmCmAEBbEBLAdgKAwFwJ7AQFEAnY+AZ22PWgwDMBXNMeACiNIEp4TiB7Yq26VqaaPADe8YrGwNiaClRrtuAXyyNm8ONgDKDAEYArWGGxC2ImgBp4sUgO4SMASAD07+FVzTYwABtwGng0FAD4AHcUbAALHlJWACJdAxMzbHtHYiTONxk5BXgkyIEAgBMku15k1KNTcyz+HLyNeiYWchBcAAlYAIC+SwdmyTdgUWwAtGS+gb47JPgAam9iXFY69PMhblWkgEJc/Nl5RTCAjDatFmR0SxdXFDom+AAuAF4KbrnBoQBuV4HL4XMauVygMJgdhcNwaDRAA===

  • Use in slipHQ/run-wasm for Go in browser support

    Use in slipHQ/run-wasm for Go in browser support

    Hello!

    I would like to use this to implement Go support in run-wasm, an open-source library for running WASM-based code executions in the browser.

    You can read about the goal for Go support here.

    A few questions before I attempt to implement this using your library:

    • What is the license for the Repo?
    • What would the difficulty be in implementing #7?
    • Would you be willing to help with the effort?

    Look forward to hearing back from you

    Nicholas

  • Support most/all of the standard library

    Support most/all of the standard library

    I know that you are aware of the lack of support of the stdlib, I just felt it warranted documentation as an issue.

    I have no idea how much time it would take to do this, or what is involved in making this happen, and of course you're free to not do this if you don't want to do it. I see a lot of value in a completely in-browser compiler and runtime.

    Thank you for what is done so far, even if it's never expanded to include the standard library!

  • Use the new go:embed feature to produce a single, self-contained binary.

    Use the new go:embed feature to produce a single, self-contained binary.

    the //go:embed compiler directive now (since Go 1.16) allows you to embed files into the compiled binary as a read-only filesystem.

    This means that you no longer need to have the files you're serving be present in the directory that you're running the executable from; they can be inside the binary itself.

    That doesn't matter a lot if you're self-hosting this, but if you want to share it with people and don't want to leave the webserver process running forever on your own machine, sharing a single binary and letting everyone use their own instance is a lot easier.

    All I had to do to make this work was change main.go to this: https://gist.github.com/naikrovek/1ba61a60b66f0bb40dbe105b09cd052e

    I don't know what would be needed for the two experimental versions of the tool.

Run WASM tests inside your browser

wasmbrowsertest Run Go wasm tests easily in your browser. If you have a codebase targeting the wasm platform, chances are you would want to test your

Dec 16, 2022
Go compiler for small places. Microcontrollers, WebAssembly, and command-line tools. Based on LLVM.

TinyGo - Go compiler for small places TinyGo is a Go compiler intended for use in small places such as microcontrollers, WebAssembly (Wasm), and comma

Dec 30, 2022
A Brainfuck to WebAssembly compiler written in Go.

brainfuck2wasm A Brainfuck to WebAssembly compiler written in Go. I am writing this compiler for a Medium article. When I complete the compiler, I'll

Jun 6, 2022
The in-browser IDE for Go

Go Wasm Go Wasm is a Go development environment with the essentials to write and run code entirely within the browser, using the power of WebAssembly

Dec 19, 2022
Interact with browser from Go. Manually-crafted WebAPI interoperation library.

GWeb: golang + js + wasm gweb -- strictly typed WebAPI library on top of syscall/js. Like flow or TypeScript but for Go. You need it if you want to in

Sep 26, 2022
Go Wasm is a in-browser IDE for Go

Go Wasm Go Wasm is a Go development environment with the essentials to write and run code entirely within the browser, using the power of WebAssembly

Jan 8, 2023
A Go unikernel running on x86 bare metal
A Go unikernel running on x86 bare metal

EggOS A Go unikernel running on x86 bare metal Run a single Go applications on x86 bare metal, written entirely in Go (only a small amount of C and so

Jan 6, 2023
Write your front in Go!

Hogosuru Hogosuru is a part of a personel project and export to the community and provide a framework to easly provide write front end in go. He use a

Dec 14, 2022
A compiler from Go to JavaScript for running Go code in a browser

GopherJS - A compiler from Go to JavaScript GopherJS compiles Go code (golang.org) to pure JavaScript code. Its main purpose is to give you the opport

Dec 30, 2022
Wirewold cellular automata simulator, running entirely on GPU.

Wireworld-gpu Wireworld implements the data and rules for the Wireworld cellular automata. This particular version is an experiment whereby the simula

Dec 31, 2022
The full power of the Go Compiler directly in your browser, including a virtual file system implementation. Deployable as a static website.
The full power of the Go Compiler directly in your browser, including a virtual file system implementation. Deployable as a static website.

Static Go Playground Features Full Go Compiler running on the browser. Supports using custom build tags. Incremental builds (build cache). Supports mu

Jun 16, 2022
Go compiler made from scratch, which can compile itself. It's going to be the smallest and simplest go compiler in the world.

Babygo, a go compiler made from scratch Babygo is a small and simple go compiler. (Smallest and simplest in the world, I believe.) It is made from scr

Jan 8, 2023
Compiler as a Service is a compiler that is available over http/https and gRPC

BlakBoks(CaaS) Elasticsearch but for compiling untrusted code Compiler as a Service is a compiler that is available over http/2 and gRPC. Setup First

Nov 24, 2021
ReCT-Go-Compiler - A compiler for the ReCT programming language written in Golang

ReCT-Go-Compiler A compiler for the ReCT programming language written in Golang

Nov 30, 2022
ReCT-Go-Compiler - A compiler for the ReCT programming language written in Golang

ReCT-Go-Compiler A compiler for the ReCT programming language written in Golang

Nov 30, 2022
Pulp allows you to write dynamic web-applications entirely in go

pulp Pulp allows you to write dynamic web-applications entirely in go, by reacting to events on the server-side. func (c index) Render(pulp.Socket) (p

Dec 5, 2022
A framework for apps written entirely in YAML, powered by ytt.

yapp A framework for apps written entirely in YAML, powered by ytt. Highly experimental! Do not use! # start the server... go run . -f examples/hello-

May 6, 2022
GoScan is a port-scanner made entirely in Go-lang. The purpose of the tool is to be fast, dynamic and simple so that a professional in the CyberSecurity area can make an optimized list of ports
GoScan is a port-scanner made entirely in Go-lang. The purpose of the tool is to be fast, dynamic and simple so that a professional in the CyberSecurity area can make an optimized list of ports

?? GoScan GoScan is a port-scanner made entirely in Go-lang. The purpose of the tool is to be fast, dynamic and simple so that a professional in the C

Jul 19, 2022
hack-browser-data is an open-source tool that could help you decrypt data from the browser.
hack-browser-data is an open-source tool that could help you decrypt data  from the browser.

hack-browser-data is an open-source tool that could help you decrypt data ( password|bookmark|cookie|history|credit card|download

Dec 23, 2022
🌭 The hotdog web browser and browser engine 🌭
🌭 The hotdog web browser and browser engine 🌭

This is the hotdog web browser project. It's a web browser with its own layout and rendering engine, parsers, and UI toolkit! It's made from scratch e

Dec 30, 2022