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

Overview

Static Go Playground

MIT license Build

Features

  • Full Go Compiler running on the browser.
    • Supports using custom build tags.
    • Incremental builds (build cache).
    • Supports multiple files and packages (including dependencies).
    • Full cross-compiling support directly from your browser.
    • No need for a server backend to build executables.
    • Easy deployment (just upload the generated files).
  • Full filesystem abstraction for both the compiler and running programs.
    • A standalone wasm_exec.js with filesystem support is available.
  • Full DOM access for running programs (and basic stdout/stderr for now).
  • Browser-based code editor (Ace).

Try it out!

Compiling and running examples from Ebiten:

Go Playground demo

Compiling and running modified examples:

Go Playground editor demo

Use this to provide editable demos for your projects!

Instructions

  1. Run go mod vendor on your Go Module root.
  2. Zip the project and upload it anywhere.
    1. Check that there are no CORS errors.
    2. You may use CI to perform these steps automatically, like this workflow for ebiten.
  3. Publish the URL that automatically loads and builds your project.
    1. Take a look at setup.ts for more information on startup automation.
    2. For example, to automatically download ebiten's sources, build and run an example use this URL.

How does it work?

This project builds the Go Compiler to WebAssembly and provides enough abstractions, fixes and hacks for it to be able to build executables (for any platform) from the web. The main added abstraction is a virtual file system implementation that works in memory (based on virtualfs), which can also be used separately with a custom wasm_exec.js. The frontend also runs the compiled code (if the target arch is js/wasm), with the same features available.

The result is a static website that can compile and run most Go code (see known limitations below) from the client's browser.

Why? To learn how the Go compiler works and to provide better (hackable) demos for most Go projects with easy deployment.

Standard library

There are 2 approaches to handle the standard library:

  • Precompiling it while building the compiler: faster first compilation but requires a bigger (slower) initial download and only supports building for one OS/arch, unless another precompiled library is downloaded.
  • Compiling the standard library from the browser (only the required packages): It allows to cross-compile to any OS/arch supported by Go at the cost of an slower initial build: compiled artifacts are cached once built for the first time (this happens automatically for all packages with unmodified sources).

A mix of both was applied: the precompiled standard library for js/wasm is downloaded. Cross-compiling is also possible because the source code of the standard library is downloaded and used for any other OS/arch.

Builds

You can download production builds from the releases or the github pages branch.

Building from source

Dependencies:

  • Go Compiler (Go 1.13 or later)
  • node and npm/yarn
  • Very common UNIX tools.

Just run make: it will output a static site to dist/ that can be uploaded to any web server. To learn how it works, start by looking at the Makefile.

To only generate the modified wasm_exec.js (already embedded if using the main app), run make wasm_exec.

Known limitations

  • Limitations of building on js/wasm:
    • No Cgo support.
  • Limitations of running on js/wasm:
    • Limited network access (available: HTTP client, WebRTC...).
    • Limited persistent storage (not implemented yet, could be blocked/deleted by user).
  • Dependencies must be vendored (due to limited network access).
  • Slower than the native compiler, and may run out of memory for large projects.

Related projects

Updated: 03/2022

  • The official Go Playground (link): limited execution time, no DOM access, no output until the program finishes, limited multi-package support.
  • Better Go Playground (link): has an experimental webassembly runtime, but includes no filesystem abstraction and still requires a server backend to build the webassembly modules, no multi-package support.
  • pdfcpu (link): Example of running a Go CLI tool on the web browser, inspiration for this project.
  • Wasm go playground (link): No standard library, no dependencies, no multi-file support, no cross-compilation, inspiration for this project
  • Go Playground WASM (link): Actually compiles Goscript (a script language like Python or Lua written in Rust, with exactly the same syntax as Go's) instead of using the official Go Compiler.
You might also like...

portfolio-project is a npm package to automatically update your projects section in your portfolio website. It will fetch the selected repositories directly from your GitHub account.

portfolio-project is a npm package to automatically update your projects section in your portfolio website. It will fetch the selected repositories directly from your GitHub account.

portfolio-project Those days of manually updating portfolio website after every new project made are gone ⚡ Yesss . . . you read that right. 😉 portfo

Aug 3, 2021

Feel free to create new file, don't hesitate to pull your code, the most important thing is that the file name here must match your nickname so that file does not conflict with other people.

Hacktoberfest Indonesia Apa Itu Hacktoberfest ? Hacktoberfest adalah acara tahunan yang bertujuan untuk mendorong berkontribusi kedalam ekosistem open

Dec 15, 2022

⚡ A blazing fast, lightweight, and open source comment system for your static website, blogs powered by Supabase

⚡ A blazing fast, lightweight, and open source comment system for your static website, blogs powered by Supabase

SupaComments ⚡ A blazing fast, lightweight, and open source comment system for your static website, blogs 🚀 Demo You can visit the Below demo blog po

Dec 27, 2022

Convert your SVG file directly to Flutter paths and prevent all the messing with bezier curves.

Convert your SVG file directly to Flutter paths and prevent all the messing with bezier curves.

svg-to-flutter-path-converter Convert your SVG file directly to Flutter paths and prevent all the messing with bezier curves. Flutter Clutter The tool

Jan 2, 2023

Minimal web3 implementation: call eth contracts directly from JS

micro-web3 Minimal web3 implementation: call eth contracts directly from JS Connect to any web3 server: host your own with execution layer client, or

Dec 29, 2022

Gofiber with NextJS Static HTML is a small Go program to showcase for bundling a static HTML export of a Next.js app

Gofiber and NextJS Static HTML Gofiber with NextJS Static HTML is a small Go program to showcase for bundling a static HTML export of a Next.js app. R

Jan 22, 2022

Google-Drive-Directory-Index | Combining the power of Cloudflare Workers and Google Drive API will allow you to index your Google Drive files on the browser.

🍿 Google-Drive-Directory-Index Combining the power of Cloudflare Workers and Google Drive will allow you to index your Google Drive files on the brow

Jan 2, 2023

🐬 A simplified implementation of TypeScript's type system written in TypeScript's type system

🐬 A simplified implementation of TypeScript's type system written in TypeScript's type system

🐬 HypeScript Introduction This is a simplified implementation of TypeScript's type system that's written in TypeScript's type annotations. This means

Dec 20, 2022

A quickstart AWS Lambda function code generator. Downloads a template function code file, test harness file, sample SAM deffiniation and appropriate file structure.

Welcome to function-stencil 👋 A quickstart AWS Lambda function code generator. Downloads a template function code file, test harness file, sample SAM

Jun 20, 2022
Comments
  • Bump terser from 5.12.1 to 5.14.2 in /frontend

    Bump terser from 5.12.1 to 5.14.2 in /frontend

    Bumps terser from 5.12.1 to 5.14.2.

    Changelog

    Sourced from terser's changelog.

    v5.14.2

    • Security fix for RegExps that should not be evaluated (regexp DDOS)
    • Source maps improvements (#1211)
    • Performance improvements in long property access evaluation (#1213)

    v5.14.1

    • keep_numbers option added to TypeScript defs (#1208)
    • Fixed parsing of nested template strings (#1204)

    v5.14.0

    • Switched to @​jridgewell/source-map for sourcemap generation (#1190, #1181)
    • Fixed source maps with non-terminated segments (#1106)
    • Enabled typescript types to be imported from the package (#1194)
    • Extra DOM props have been added (#1191)
    • Delete the AST while generating code, as a means to save RAM

    v5.13.1

    • Removed self-assignments (varname=varname) (closes #1081)
    • Separated inlining code (for inlining things into references, or removing IIFEs)
    • Allow multiple identifiers with the same name in var destructuring (eg var { a, a } = x) (#1176)

    v5.13.0

    • All calls to eval() were removed (#1171, #1184)
    • source-map was updated to 0.8.0-beta.0 (#1164)
    • NavigatorUAData was added to domprops to avoid property mangling (#1166)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Patch os/exec

    Patch os/exec

    Patching os/exec of the go standard library would allow go build to work normally (avoiding the current buildhelper hack) and would support more programs.

    enhancement 
    opened by Yeicor 0
Releases(v0.1.0)
Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all with IndexedDB. Perfectly suitable for your next (PWA) app.

BrowstorJS ?? ?? ?? Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all

Nullix 8 Aug 5, 2022
A large scale simulation which pits millions of space ships against each other in a virtual universe all running directly in SingleStore.

Wasm Space Program In this demo we simulate a fake universe full of thousands of solar systems. In each solar system there are many space ships and en

SingleStore Labs 11 Nov 2, 2022
A block preview that directly displays the block fields, including tabs.

Kirby Block Preview Fields This plugin for Kirby 3 displays the block fields directly in the block preview, including tabs. Inspired by the Kirby Fiel

JUNO 8 May 10, 2023
Serve file server with single zip file as file system in Deno.

zipland Serve file server with one-single zip file in Deno. Support zip just zip32 with deflated or uncompressed serving plaintext deflate Examples Yo

Yongwook Choi 18 Nov 2, 2022
An implementation of the Dungeons & Dragons 5th Edition game system for Foundry Virtual Tabletop

An implementation of the Dungeons & Dragons 5th Edition game system for Foundry Virtual Tabletop.

Foundry Virtual Tabletop 103 Jan 2, 2023
Template of yew project, using tailwind and webpack for css, trunk for build and serve, deployable as is for github.io

Yew Template for Github.io Yew template that deployable as is for github.io (or as a normal yew template with css/scss stuffs without github.io), with

null 17 Dec 23, 2022
The Frontend of Escobar's Inventory Management System, Employee Management System, Ordering System, and Income & Expense System

Usage Create an App # with npx $ npx create-nextron-app my-app --example with-javascript # with yarn $ yarn create nextron-app my-app --example with-

Viver Bungag 4 Jan 2, 2023
A Laravel Blade parser, compiler, and static analyzer written in TypeScript.

Blade Parser This library provides a Laravel Blade parser written in TypeScript. In addition to being able to parse Blade template files, this library

Stillat 7 Jan 4, 2023
JSON Visio is data visualization tool for your json data which seamlessly illustrates your data on graphs without having to restructure anything, paste directly or import file.

JSON Visio is data visualization tool for your json data which seamlessly illustrates your data on graphs without having to restructure anything, paste directly or import file.

Aykut Saraç 20.6k Jan 4, 2023