Skip to content

Commit c46b032

Browse files
authored
Merge pull request #80 from grantnelson-wf/updateTo1_19
Update to Go 1.20 and React with line numbers
2 parents 88843ad + 3e2519d commit c46b032

498 files changed

Lines changed: 458086 additions & 1543 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
playground/go.sum linguist-generated
2+
playground/internal/cmd/precompile/go.sum linguist-generated
3+
4+
**/*.a.js linguist-generated
5+
playground/playground.js linguist-generated
6+
7+
playground/internal/imports/zstdlib.go linguist-generated

.github/workflows/ci.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
pull_request:
7+
branches: [ "*" ]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
GO_VERSION: 1.20.14
19+
NODE_VERSION: 18
20+
GOLANGCI_VERSION: v1.53.3
21+
SOURCE_MAP_SUPPORT: true
22+
GOPATH: ${{ github.workspace }}/go
23+
GOPHERJS_PATH: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
24+
25+
jobs:
26+
lint:
27+
name: Lint Checks
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
path: ${{ env.GOPHERJS_PATH }}
33+
- uses: actions/setup-go@v5
34+
with:
35+
go-version: ${{ env.GO_VERSION }}
36+
- name: Install golangci-lint
37+
uses: golangci/golangci-lint-action@v3
38+
with:
39+
working-directory: ${{ env.GOPHERJS_PATH }}/playground
40+
version: ${{ env.GOLANGCI_VERSION }}
41+
only-new-issues: true
42+
- name: Check go.mod
43+
working-directory: ${{ env.GOPHERJS_PATH }}/playground
44+
run: go mod tidy && git diff --exit-code
45+
46+
go_tests:
47+
name: Go Tests
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
with:
52+
path: ${{ env.GOPHERJS_PATH }}
53+
- name: Setup Go
54+
uses: actions/setup-go@v5
55+
with:
56+
go-version: ${{ env.GO_VERSION }}
57+
- name: Setup Go Environment
58+
working-directory: ${{ env.GOPHERJS_PATH }}
59+
shell: bash
60+
run: echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
61+
- name: Run Playground Tests
62+
working-directory: ${{ env.GOPHERJS_PATH }}/playground
63+
run: go test -v -race ./...

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/playground/playground.js.map
2+
/playground/compile.js.map
3+
.DS_Store

go.work

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
go 1.20
2+
3+
use (
4+
./playground
5+
./playground/internal/cmd/compile
6+
./playground/internal/cmd/precompile
7+
)

go.work.sum

Lines changed: 610 additions & 0 deletions
Large diffs are not rendered by default.

playground/README.md

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,85 @@
22

33
The playground is a place where users can explore GopherJS without needing to install anything, or to share code with others.
44

5+
- [Building the playgound](#building-the-playgound)
6+
- [Development](#development)
7+
- [Upgrading GopherJS release](#upgrading-gopherjs-release)
8+
- [Adding a new predefined snippet](#adding-a-new-predefined-snippet)
9+
10+
## Building the playgound
11+
12+
To build the entire playground environment,
13+
run `go generate`.
14+
15+
This assumes that your `go` matches the current version of `go` that `gopherjs` supports.
16+
If you have a different version of `go` then install the other versions as
17+
described in [Managing Go installations](https://go.dev/doc/manage-install).
18+
19+
For example, to build for [GopherJS 1.20.0 for Go 1.20.14](https://github.com/gopherjs/gopherjs/releases/tag/v1.20.0)
20+
run `go1.20.14 generate`.
21+
22+
Generate will:
23+
24+
1. Install your local version of GopherJS compiler
25+
2. Build the playground
26+
3. Build the web worker compiler
27+
4. Create precompiled standard library packages in the `pkg` directory
28+
29+
To manually build the playground:
30+
31+
1. See [GopherJS](https://github.com/gopherjs/gopherjs) documentation about building GopherJS
32+
2. Build the playgound with `gopherjs build ./playground.go`
33+
3. Build the web worker compiler with `gopherjs build ./internal/cmd/compile/compile.go`
34+
4. Create the precompiled standard library packages with `go run ./internal/cmd/precompile`.
35+
Use the same `go` as `gopherjs` as described above
36+
537
## Development
638

7-
To update the entire playground environment, just run `go generate github.com/gopherjs/gopherjs.github.io/playground`. It will install your local version of GopherJS compiler, build the playground, make a temporary copy of Go to /tmp/gopherjsplayground_goroot, rebuild and copy the standard library into the `pkg` directory.
39+
Working on the playground application itself is made easier by using the
40+
`gopherjs serve` command serve the playground locally.
841

9-
Working on the playground application itself is made easier by using the `gopherjs serve` command to rebuild and serve the playground every time you refresh the browser.
42+
Then open <http://localhost:8080?debug=true&local=true>.
1043

11-
```bash
12-
gopherjs serve
13-
```
44+
The `debug` query will enable debugging for react and verbose output.
45+
46+
If running locally or from a fork, trying to access the remote store will
47+
fail with a a CORS error. Use the `local` query to make the snippet store
48+
(used when clicking "Share" or loading with a shared url) use local cache only.
49+
50+
There are a few ways to check changes. When working on the playground itself
51+
it may be simpliest to run `gopherjs build ./playground.go && gopherjs serve`
52+
after you have made changes so that the changes will be built and served.
1453

15-
Then open <http://localhost:8080/github.com/gopherjs/gopherjs.github.io/playground>.
54+
When running code in the playground, the JS that is being run can be seen
55+
by checking the page source files and finding the webworker that is running
56+
the code. The webworker should have a GUID name, e.g. `fb29b3a9-d5b0-478d-aaf7-85cb60ddbd6d`,
57+
and the JS compiled for that code will have the same name (usually without `.js`).
1658

1759
## Upgrading GopherJS release
1860

61+
To upgrade to the newest version, run
62+
1963
```shell
2064
VERSION="$(go list -m -versions -f "{{ range .Versions }}{{ println . }}{{ end }}" github.com/gopherjs/gopherjs | tail -n 1)"
2165
echo "$VERSION"
2266
go get -v "github.com/gopherjs/gopherjs@$VERSION"
2367
go mod tidy
2468
```
69+
70+
then rebuild the playground with the correct version of `go`.
71+
72+
When committing the update, make sure that `compile.js` at minimum has been
73+
updated to use the new version of GopherJS so that we can build in that version.
74+
75+
## Adding a new predefined snippet
76+
77+
The snippets are prewritten example programs such as `Hello` and `Donut`.
78+
To add new snippets:
79+
80+
1. Write the code you would like to add
81+
2. Test it in the playground and check the console to make sure it does
82+
what you expected it to do
83+
3. Create file in the [snippets folder](./internal/snippets) for that code and change
84+
file extension to `.go.txt`
85+
4. In [`snippets.go`](./internal/snippets/snippets.go) add the new file as
86+
an embedded string and add that string to the `predefined` map.

0 commit comments

Comments
 (0)