Go compiler running entirely in your browser

Overview

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.
Issues
  • 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.

    opened by jantebeest 2
  • 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

    opened by stefanb 2
  • 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===

    opened by ccbrown 0
  • 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

    opened by ntindle 0
  • 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!

    opened by naikrovek 0
  • 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.

    opened by naikrovek 0
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

Agniva De Sarker 127 Jul 13, 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

TinyGo 11.3k Aug 11, 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

Luke I. Wilson 2 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

John Starich 438 Aug 8, 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

Life4 183 Jul 12, 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

John Starich 438 Aug 8, 2022
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

fanbingxin 1.9k Aug 8, 2022
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

null 30 Aug 13, 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

GopherJS 11.3k Aug 12, 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

null 0 Nov 26, 2021
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

null 25 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

DQNEO 221 Aug 16, 2022
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

Nathan Kimutai 0 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

RedCubeDev 6 Apr 7, 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

null 6 Apr 7, 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 ( password|bookmark|cookie|history|credit card|download

idiotc4t 105 Aug 2, 2022
🌭 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

Danilo Fragoso 1k Aug 15, 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

malte.l 19 Jul 8, 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-

Reid Mitchell 4 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 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

Ottoni 4 Jul 19, 2022
Host yo' self from your browser, your phone, your toaster.

A hosting service from the browser, because why not. Try it at hostyoself.com. See it in action Here's an example where I use hostyoself.com to host i

Zack 1.7k Aug 9, 2022
Running a Command line tool written in Go on browser with WebAssembly

Running a command line tool written in Go on browser with WebAssembly This repo contains code/assets from the article Files: . ├── article.md

wcchoi 79 Jul 3, 2022
Op - A small tool that will allow you to open language or framework documentation in your browser from your terminal

op "op" is a small tool that will allow you to open language or framework docume

Damien Sedgwick 3 Apr 14, 2022
Promise to the Go compiler that your Reads and Writes are well-behaved

noescape go get lukechampine.com/noescape noescape provides Read and Write functions that do not heap-allocate their argument. Normally, when you pas

Luke Champine 33 Jun 30, 2022
:rocket: Instant live visualization of your Go application runtime statistics (GC, MemStats, etc.) in the browser

Statsviz Instant live visualization of your Go application runtime statistics (GC, MemStats, etc.). Import "github.com/arl/statsviz" Register statsviz

Aurélien Rainone 1.9k Aug 12, 2022
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

Agniva De Sarker 127 Jul 13, 2022
Open URL in your local web browser from the SSH-connected remote environment.

opener Open URL in your local web browser from the SSH-connected remote environment. How does opener work? opener is a daemon process that runs locall

Kazuki Suda 55 Jun 29, 2022
Deskreen turns any device with a web browser into a secondary screen for your computer

Deskreen Website: https://deskreen.com ▶️ Deskreen Youtube channel (video tutorials, demos, use cases for Deskreen day to day usage) Deskreen turns an

Paul Pavlo Buidenkov 13.3k Aug 18, 2022
Python's webbrowser in Go. Simple API for opening web pages on your default browser.

webbrowser webbrowser provides a simple API for opening web pages on your default browser. It's inspired on Python's webbrowser package but lacks some

Carlos Cobo 175 Jul 20, 2022