jsgo playground: edit and run Go code in the browser, supporting arbitrary import paths
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
actions Refactor May 27, 2018
models Frizz client scans for types Jun 3, 2018
stores Remove listener after trigger Jun 16, 2018
testing Add testing Apr 5, 2018
views Patreon link Aug 14, 2018
.gitignore Move to new repo Mar 22, 2018
LICENSE Create LICENSE Aug 11, 2018
README.md Add readme section for running locally Sep 27, 2018
index.html Add GA May 4, 2018
index.jsgo.html Add GA May 4, 2018
main.go Removed css in main May 17, 2018
main_test.go Refactor May 29, 2018

README.md

Edit and run Go in the browser, supporting arbitrary import paths!

https://play.jsgo.io/

title936803092

The jsgo playground is an extension of the jsgo compiler. The compiler allows you to easily compile Go to JS using GopherJS, and automatically host the results in an aggressively cached CDN. The playground adds an online editor and many other features (see below).

The unique feature of the jsgo playground is that it supports arbitrary import paths. Other Go playgrounds are limited to just the Go standard library.

For more for more info:

Demos

Here's the simplest demo - it just writes to the console and to the page:

Here's a couple of simple demos that accept files by drag and drop. The first compresses dropped files to a zip. The second compresses images to jpg. They use the Go standard library zip / image libraries, which work flawlessly in the browser:

The amazing ebiten 2D games library is a perfect example of the power of Go in the browser. Here's some demos:

Contact

If you'd like to chat more about the project, feel free to add an issue, mention @dave or post in the #gopherjs channel of the Gophers Slack. I'm happy to help!

Features

Initialise

The URL can be used to initialise with code in several ways:

  • Load a Go package with /{{ Package path }}
  • Load a Github Gist with /gist.github.com/{{ Gist ID }}
  • Load a shared project with /{{ Share ID }}
  • Load a play.golang.org share with /p/{{ Go playground ID }}

run

Run

Click the Run button to run your code in the right-hand panel. If the imports have been changed recently, the dependencies will be refreshed before running.

format

Format code

Use the Format code option to run gofmt on your code. This is executed automatically when the Run, Update, Share or Deploy features are used.

update

Update

If you update a dependency, use the Update option, which does the equivalent of go get -u and refreshes the changes in any import or dependency.

share

Share

To share your project with others, use the Share option. Your project will be persisted to a json file on src.jsgo.io and the page will update to a sharable URL.

deploy

Deploy

To deploy your code to jsgo.io, use the Deploy feature. A modal will be displayed with the link to the page on jsgo.io, and the Loader JS on pkg.jsgo.io.

Use the jsgo.io link for testing and toy projects. Remember you're sharing the jsgo.io domain with everyone else, so the browser environment should be considered toxic.

The Loader JS on pkg.jsgo.io can be used in production, and should be added to a script tag on your own website. See github.com/dave/jsgo for more information.

console

Console

Writes to os.Stdout are redirected to a playground console, which can be toggled using the Show console option. The console will automatically appear the first time it's written to.

minify

Minify

In normal usage, all JS is minified. For debugging, this can be toggled with the Minify JS option.

tags

Build tags

The build tags used when compiling can be edited with the Build tags... option. The selected build tags are persisted when using the Share feature.

download

Download

The Download option downloads the project. Single file projects are downloaded as a single file, while multi-file projects download as a zip.

download

Upload

Files can be uploaded to the project simply by drag+drop. Zip files generated by the Download feature can be uploaded to restore a multi-file project.

files

File menu

Change the selected file with the file menu.

add-file

Add file

Add a file to the current package with the Add file option. Only .go, .md and .inc.js files are supported. If no extension is supplied, .go is added.

delete-file

Delete file

Delete a file from the current package with the Delete file option.

package

Package menu

Change the selected package with the package menu.

add-package

Add package

Add an empty package with the Add package option.

load-package

Load package

The source for an import or dependency can be loaded with the Load package option. By default, only the direct imports of your project are listed. Use the Show all dependencies option to show the entire dependency tree.

remove-package

Remove package

A package can be removed with the Remove package option.

Run locally?

If you'd like to run play.jsgo.io locally, take a look at these instructions.