The in-browser IDE for Go

Overview

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 (Wasm).

Check out the article announcement on Medium, and the demo at https://go-wasm.johnstarich.com

Contributing

Want to discuss an idea or a bug? Open up a new issue and we can talk about it. Pull requests are welcome.

Issues
  • caching and etags semantics and perhaps wider reuse patterns

    caching and etags semantics and perhaps wider reuse patterns

    Hey @JohnStarich

    Hope all is well.... I am really fascinated with your project and wider implications of this.

    I am not sure if this issue / question shoudl be here or in the FS repo but here goes....

    One thing i am working on is the relationship between retained mode GUI's and data caches. A retained mode gui can be conceptually designed like a data cache system that we all know and love. A gui has a template that is computed on to produce some markup. In a retained mode gui system you want to know if the template has changed. It woudl be a signal at the control plane level (if you get my drift), so you can do optimistic re rendering of that gui component instance, which is sort of like eager caching. Hope that this is making sense :)

    Some background might also help... I know this is pretty out there... The DOM is a browser is doing the retained mode diffing for you. It knows when you changed the HTML in the inspector, and magically updates the HTML Screen for you. But when you working at the WASM level and rendering with WASM to a Webgl canvas, you need to do this yourself..

    So now i get to my question... The FS implementation is super cool because it can work with a WASM, local or remote context, but i was wondering if it supports etags style caching or other meta data semantics to tell the caller that you need to do a cache miss and refetch because your local data is old buddy !!

    Golang Http FS has etags: https://go.googlesource.com/go/+/go1.8.3/src/net/http/fs.go; see line 119. So it can easily act as a cache to a DB called over http for example.

    The reason i bring this up is because you also want to do the same thing inside the WASM environment for many use cases. Let say in the WASM environment you have a FS ( that is indexeddb under the hood) that is sourced from S3. When the S3 source changes, i presume there is some sort of etag header to tell you. So you want when in the WASM environment there is a call to the WASM FS, it should realise that the local FS is now "dirty" or "invalidated" and so it should automatically get the data from S3, update the local file, and return that to the caller.

    So i am wondering if this is currently supported.

    It will be really interesting to see how this also related to the Web Worker and Service Worker stuff too Service Worker.

    It will be really interesting to build quasi CDN like architectures where you can have caches at the WASM, local and remote level like a CDN style architecture. An thew also cross mix. Markup templates are dependent on data which can be dependent on the caache and its "turtles all the way down"..... I like the simplicity of this.

    You also get into a interesting situation with Design time versus Runtime also. I use the work real time because the IDE is running in a browser and doing compilation as you change code. At non real time, you working off already compiled golang. At real time Design time, you want your goimport to be always latest and when someone else PR#s some code that you import you want to know NOW and see it and adapt. you want to get broken by them ... At Real time Runtime, you want to use a static version, and not break.

    The same does for data. YOu have static data ( json, binaries, etc) and you have dynamic data. At Real time Design time, you want everything to be dynamic. Don't use any caching anywhere. At real time Runtime, you want everything that is static to never update, and everything that's dynamic to use the cache mechanism.

    opened by gedw99 8
  • The building process seems to be very slow

    The building process seems to be very slow

    Hello and thank you for making this! For some reasons I cannot understand, the build process seems to be very slow. I am waiting for more than 5 minutes and still it didn't finish. I wonder if it is browser related;I am using Firefox un GNU/Linux 89 on a 64x machine.

    opened by cmarincia 5
  • Test cases

    Test cases

    This definitely is a fascinating project. The docker ceo apparently said that if WASM existed there would have been no need for docker. He was referring to sand boxing.

    Did you hit many bugs when attempting compilation using tinygo. I think they did a release recently or it might still be on a branch . Tinygo is efficient enough that you could run on mobile or have a good chance.

    I have a interesting idea. Your sage accounting software uses a bucket file system dB and a git based vcs to presumerable allow sync of the underlying files . Would be interesting test case if these two work running on top of the wasm indexdb / FS. It’s a decent test case I feel.

    Would badger dB in theory work ?

    opened by gedw99 3
  • Race condition in pub sub

    Race condition in pub sub

    https://github.com/JohnStarich/go-wasm/blob/fd0edf41a665e400fef3db6616772439ce4b9738/internal/pubsub/pubsub.go#L40

    Go routines A and B call emit(). Both see that visited == false under read lock. A acquires write lock and processes. B acquired right lock and double processes, even though A marked the node as visited. The fix is to check if visited again after write lock is acquired

    opened by hherman1 3
  • Seeing error

    Seeing error "package fmt is not in GOROOT (/usr/local/go/src/fmt)" in attempting hello world on hackpad.org

    Seeing the following error, see linked screenshot below: Screenshot 2022-05-06 4 08 51 PM

    Terminal text here for convenience also:

    $ go version
    go version go1.16.6 js/wasm
    $ go mod init playground
    go: creating new go.mod: module playground
    go: to add module requirements and sums:
    	go mod tidy
    $ go mod tidy
    $ go build -v .
    main.go:4:2: package fmt is not in GOROOT (/usr/local/go/src/fmt)
    package playground: cannot find package
    exit status 1
    

    Any ideas what I might be doing wrong here? Thanks!

    opened by aaron-prindle 2
  • Switch filesystem to hackpadfs

    Switch filesystem to hackpadfs

    Switches to hackpadfs for filesystem setup, tests, and implementations. Parts of its original ideas were extracted from go-wasm, but it evolved into a totally new implementation.

    Hackpadfs has proper tests, interface design, and documentation. All of which should help improve stability, isolation, and performance of go-wasm in the long run.

    Further, the indexeddb adapter is much improved in its new home go-indexeddb.

    opened by JohnStarich 0
  • Add vet and cover tools

    Add vet and cover tools

    Add vet and cover go tool support.

    Also add a jsdownload builtin command for the shell. This makes it possible to generate coverage files for Wasm-only tests and then parse them on your own machine.

    i.e.

    # in Go Wasm
    go test ./... -coverprofile=cover.out
    jsdownload cover.out
    # locally
    go tool cover -html cover.out
    

    Perhaps eventually coverage can be fully integrated into the editor itself.

    opened by JohnStarich 0
  • Fix overlapped vertical scrollbar

    Fix overlapped vertical scrollbar

    When one go beyond the editor viewport, the scrollbar overlaps the original one (which doesn't seem to have any utility). So, in order to avoid this situation, the 'original' vertical scrollbar has been remove.

    Before: before

    After: after

    opened by kkkk-source 0
  • Lower memory usage from compiling and running binaries

    Lower memory usage from compiling and running binaries

    Lowers memory usage for running binaries like go, compile, and user programs.

    Memory decreased by up to 56% in the best case and 47% in the worst case. The heap footprint should now remain below 250 MB in the worst case, down from 540 MB. On a second boot (not installing the Go toolchain), memory usage is reduced even further to below 180 MB. Execution times shortened a bit, but probably within margin of error.

    See below for single samples of performance changes. These are super rough, so take them with a grain of salt.

    Master branch:

    • First boot:
      • Init = 59.04s; 297 MB heap
      • Compile = 179.18s
      • Run = 0.20s; 540 MB heap
    • Second boot (after reload):
      • Init = 0.85s; 224 MB heap
      • Compile = 27.95s
      • Run = 0.12s; 394 MB heap

    This PR:

    • First boot:
      • Init = 64.35s; 156 MB heap -47%
      • Compile = 164.41s
      • Run = 0.13s; 245 MB heap -55%
    • Second boot:
      • Init = 0.94s; 104 MB heap
      • Compile = 25.06s
      • Run = 0.10s; 175 MB heap -56%

    I'd summarize the commits, but they were enough changes it'd probably be best to read through the commit messages themselves.

    opened by JohnStarich 0
  • Shell auto-completion, editor DOM interface pkg & settings dropdown

    Shell auto-completion, editor DOM interface pkg & settings dropdown

    • Upgrade to Go 1.16 (compiler & runtime compiler)
    • Improve mount handling for long-running FS calls
    • Add new dom package for clearer interop and compile safety in the editor
    • Add basic auto-completion for file paths in the shell
    • Add support for ~ meaning /home/me in the shell
    • Add settings dropdown in editor for easy IDB FS management, like dropping the build cache or Go installation
    opened by JohnStarich 0
  • Add and use IndexedDB file system to reduce memory usage

    Add and use IndexedDB file system to reduce memory usage

    The net of all of the below changes is: Significantly reduced memory usage and persistent files. Typical memory usage has dropped from ~750 MB to ~250 MB. This is a big leap architecturally, but we still have room to improve going forward. 🎉

    Since the outrageous memory usage in the current release causes crashes on typical devices, we needed to store files somewhere other than RAM. In switching to a non-RAM storage medium, naturally go-wasm slowed down a bit. This speed difference can be further reduced in future PRs.

    As a bonus, Safari now almost works as well as Chrome and Firefox. It's still rather unhappy with the memory usage, though. Pro tip: Safari basically hangs if you run WebAssembly.compile around 100 times on the same data. Best to avoid that.

    • Fixes critical bugs in the previously experimental IndexedDB file system.
    • Overlays IDB FS's on the Go installation directory, the home dir (editor files), and the system cache dir.
      • Reconfigures Go Modules cache directory to sit on the system cache dir, too.
    • Heavily optimizes both IDB FS and tarfs for execution speed. In particular, utilizes "batched parallelism" to queue up large numbers of file operations and completing them all in one pass on the FS end.
    • Rips out tarfs custom file storage and replaced with an afero.Fs interface. Enabled easy swap-in of IDB FS.
    • New blob.Blob abstraction, to significantly reduce conversion costs between []byte and Uint8Array
    • Adds a bit of a hack to support synchronous chdir on a strictly asynchronous valid directory file system check. It works, but it ain't great.
    • Adds shell history in ~/.history. Persisted with home dir IDB FS.
    • Fixes compatibility with Go 1.16beta1, namely adding go mod tidy to first boot.
    • Fixes PATH environment variable propagation.
    • Fleshes out Go memory profile downloads a bit.
    • Adds JS property name caching, since decode() is surprisingly slow, relative to everything else.
    • Fixes an issue with stdout/stderr new lines not rendering correctly in the terminal.
    • Makes sh more robust, with time and touch support, plus a new long format -l flag for ls .
    • Fixes file timestamp conversions. (It helps when "today" is even remotely in this decade.)

    Thanks to @guest271314 for the helpful nudge #4 ❤️

    opened by JohnStarich 0
  • [RFC] refactor: update to go 1.19

    [RFC] refactor: update to go 1.19

    Marked RFC until these are merged:

    • https://github.com/paralin/go/tree/hackpad/release-branch.go1.19
    • https://github.com/hack-pad/hackpadfs/pull/20

    Fixes #25

    opened by paralin 0
  • Editing the editor (tutorial platform)

    Editing the editor (tutorial platform)

    Hey, This is super cool. I have wanted for quite some time to build tutorials for the Go language using wasm (in browser) - you have probably jump started my work here by a mile. The first step is to make a super interactive platform and a 'framework' for the tutorials so its fast and easy to add new ones.

    Thoughts:

    • left hand side panel where the instructions for this step/tutorial are
    • pre written tests that can check the results are correct - I don't want to use regex parsing stdout or something, I want real Go tests to run against functions (students add their function call to the test harness so they can call functions whatever they want - part of learning is the tests.
    • tutorials can use libraries that already exist (your platform offers this)
    • I can use mockers (smocker) to mock out external services in tutorials
    • I can run other Go apps/binaries that expose ports or something to interact with (e.g an API running locally)

    Questions

    left hand side panel where the instructions for this step/tutorial are

    I looked through the code and see you are designing/rendering the UI in Go which was amazing/surprising. Two questions really - one is do you have a link to tutorial in how you are doing this, and secondly, could this be swapped out for HTML/CSS/JS or React or something easily? My guess is WASM means better to do all in Go, so question one is more the focus - i.e can you point me to anything to learn how to adjust the UI?

    pre written tests that can check the results are correct - I don't want to use regex parsing stdout or something, I want real Go tests to run against functions (students add their function call to the test harness so they can call functions whatever they want - part of learning is the tests.

    This sounds possible based on your "OS" - Would be cool if tests can run against code?

    I can use mockers (smocker) to mock out external services in tutorials I can run other Go apps/binaries that expose ports or something to interact with (e.g an API running locally)

    I suspect these last two are closely related and its either "thats easy" or "thats hard" as the OS isn't really "real".....

    Anyway would love just to hear your thoughts on this usecase for this platform. Thanks

    opened by amlwwalker 1
  • cant run

    cant run "web-workers-2" branch

    Had some time to jump into this rabbit hole again and playing around with File System explorer module, so you get a tree.

    On origin/feature/web-workers-2 branch

    This is my simple make script that wraps your make script..

    "make serve" does not work for me. Any ideas ?

    
    build-init:
    	# installs special go.
    	cd $(REPO_NAME) && $(MAKE) go
    
    build:
    	# builds the many wasm and then the server npm stuff.
    	cd $(REPO_NAME) && $(MAKE) build
    
    serve:	
    	cd $(REPO_NAME) && $(MAKE) serve
    
    opened by gedw99 3
  • Run processes in web workers, use message passing for orchestration

    Run processes in web workers, use message passing for orchestration

    Closes https://github.com/hack-pad/hackpad/issues/11

    This is currently a huge refactor and a work in progress. Hopefully will suss out the major bugs soon 😅

    opened by JohnStarich 0
  • HTTP Server

    HTTP Server

    Hey, did you know that you can intercept requests using service workers (in the web). And in this way make a virtual tcp server which can later be used for http servers

    opened by Innovativenut 3
Owner
John Starich
Full stack software engineer
John Starich
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 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.gol

Chris 235 Jul 20, 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
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
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
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 3, 2022
LiteIDE is a simple, open source, cross-platform Go IDE.

LiteIDE X Introduction LiteIDE is a simple, open source, cross-platform Go IDE. Version: X37.3 (support Go modules) Author: visualfc Features Core fea

null 6.9k Aug 13, 2022
gide is an IDE framework in pure Go, using the GoGi gui. It extensively adopts emacs keybindings.

Gide Gide is a flexible IDE (integrated development environment) framework in pure Go, using the GoGi GUI (for which it serves as a continuous testing

GoKi 116 Aug 4, 2022
Eclipse IDE for the Go programming language:

Project website: http://goclipse.github.io/ As of 2017, Goclipse is no longer actively maintained, see this blog post for more information. If you are

null 846 Aug 15, 2022
Web-based IDE for the Go language

Welcome to godev! The aim of this project is to develop a premier Go language IDE hosted in a web interface. This was inspired by the way that the god

Chris McGee 348 Jul 7, 2022
golab: go local application builder - a web-based golang ide

golab golab was a Go IDE for Linux. This project is no longer maintained and might not build due to chganges in dependency projects. The author (mb0)

Martin Schnabel 150 Aug 8, 2022
A Golang plugin collection for SublimeText 3, providing code completion and other IDE-like features.

GoSublime Intro GoSublime is an IDE-like plugin for Sublime Text 3 mainly, but not limited to, providing integration for most of your Go/Golang develo

null 3.4k Aug 8, 2022
A tool that helps you write code in your favorite IDE: your word processor!

WordIDE Have you ever wondered: How would it feel like to write code in a word processor? Me neither. But after months minutes of planning, I present

unsafecast 35 Jul 21, 2022
Lens - The Kubernetes IDE

Lens - The Kubernetes IDE ("Lens IDE") is a distribution of the OpenLens repository with Team Lens specific customizations released under a traditional EULA.

Lens - The Kubernetes IDE 19.1k Aug 6, 2022
The Fyne IDE

DEFyne This repo contains the work-in-progress Fyne IDE. Features Embedded terminal TODO Various types of editor Syntax highlighting Standard run/test

Fyne.io 73 Aug 8, 2022
Go lang IDE. Built with GopherSauce

IDE runs as a server and is accessed via web browser. Being a web server, the IDE boasts a web (HTML) interface is accessible from any device on your network.Compared to Microsoft VS Code and Eclipse CHE, this IDE is very minimalistic

The Strukture IDE 347 Jul 29, 2022
The open-source collaborative IDE for your databases.

The open-source collaborative IDE for your databases in your browser. About Slashbase is an open-source collaborative IDE for your databases in your b

Slashbase 322 Jul 25, 2022
Web based, Go IDE.

Strukture IDE Beta II Go lang IDE. Built with GopherSauce About project IDE runs as a server and is accessed via web browser. Being a web server, the

The Strukture IDE 347 Jul 29, 2022
ide-gen is a tool for development workspace prepare automation by automatic VCS repositories discovery and clone and project generation for supported IDEs.

ide-gen is a tool for development workspace prepare automation by automatic VCS repositories discovery and clone and project generation for supported IDEs.

null 8 May 8, 2022
GoLang Library for Browser Capabilities Project

Browser Capabilities GoLang Project PHP has get_browser() function which tells what the user's browser is capable of. You can check original documenta

Maksim N. 41 Jul 22, 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 6, 2022
Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.

GoConvey is awesome Go testing Welcome to GoConvey, a yummy Go testing tool for gophers. Works with go test. Use it in the terminal or browser accordi

SmartyStreets 7.4k Aug 12, 2022
Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.

?? Playwright for API reference | Example recipes Playwright is a Go library to automate Chromium, Firefox and WebKit with a single API. Playwright is

Max Schmitt 887 Aug 11, 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
A kafka command line browser

kcli Kcli is a kafka read only command line browser. Install Binaries are provided here (windows is not tested). If you have go (1.11 or greater) inst

Craig Swank 180 Jul 29, 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
Simple in Pure Go in Browser Interactive Interpreter

GoBook This project is a PoC Don't take it seriously The main point of this project is the use of the library: github.com/brendonmatos/golive Maybe th

Brendon Ferreira 24 Feb 22, 2022
Decrypt passwords/cookies/history/bookmarks from the browser.

hack-browser-data is an open-source tool that could help you decrypt data ( passwords|bookmarks|cookies|history ) from the browser. It supports the most popular browsers on the market and runs on Windows, macOS and Linux.

ᴍᴏᴏɴD4ʀᴋ 5.1k Aug 9, 2022