Skip to content

Commit 0846560

Browse files
authored
fix: update wasm_exec.js path (#483)
* fix: update Go bridge * fix: update wasm_exec path * chore: require Go 1.24
1 parent 7aea3fc commit 0846560

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

HACKING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ Please ensure that you have installed:
7373
* Git
7474
* [Node Version Manager](https://github.com/nvm-sh/nvm) or Node.js 20 (`lts/iron`)
7575
* [Yarn](https://yarnpkg.com/) package manager.
76-
* Go 1.22+
76+
* Go 1.24+
7777
* Protobuf:
78-
* [protoc](https://developers.google.com/protocol-buffers)
79-
* [Protobuf Go plugins](https://grpc.io/docs/languages/go/quickstart/)
78+
* [protoc](https://developers.google.com/protocol-buffers)
79+
* [Protobuf Go plugins](https://grpc.io/docs/languages/go/quickstart/)
8080

8181
### First-time setup
8282

build.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ build-ui:
6363

6464
.PHONY: wasm_exec.js
6565
wasm_exec.js:
66-
@cp "$(GOROOT)/misc/wasm/wasm_exec.js" $(UI)/src/lib/go/wasm_exec.js
66+
@cp "$(GOROOT)/lib/wasm/wasm_exec.js" $(UI)/src/lib/go/wasm_exec.js
6767

6868
.PHONY:build-webworker
6969
analyzer.wasm:

build/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ARG NODE_VERSION=20
2-
ARG GO_VERSION=1.21
2+
ARG GO_VERSION=1.24
33
ARG WASM_API_VER=v2
44
ARG APP_VERSION=1.0.0
55
ARG GITHUB_URL='https://github.com/x1unix/go-playground'
6-
ARG PREV_GO_VERSION=1.19
6+
ARG PREV_GO_VERSION=1.23
77

88
FROM node:${NODE_VERSION}-alpine AS ui-build
99
ARG APP_VERSION

web/src/lib/go/node/fs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface IFileSystem {
4545
*/
4646
export interface IWriter {
4747
// write writes data and returns written bytes count
48-
write: (data: ArrayBuffer) => number
48+
write: (data: ArrayBufferLike) => number
4949
}
5050

5151
/**
@@ -62,6 +62,7 @@ export class FileSystemWrapper {
6262
O_TRUNC: -1,
6363
O_APPEND: -1,
6464
O_EXCL: -1,
65+
O_DIRECTORY: -1,
6566
}
6667

6768
constructor(stdout: IWriter, stderr: IWriter) {

web/src/lib/go/wasm_exec.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if (!globalThis.fs) {
1515
let outputBuf = "";
1616
globalThis.fs = {
17-
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
17+
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_DIRECTORY: -1 }, // unused
1818
writeSync(fd, buf) {
1919
outputBuf += decoder.decode(buf);
2020
const nl = outputBuf.lastIndexOf("\n");
@@ -73,6 +73,14 @@
7373
}
7474
}
7575

76+
if (!globalThis.path) {
77+
globalThis.path = {
78+
resolve(...pathSegments) {
79+
return pathSegments.join("/");
80+
}
81+
}
82+
}
83+
7684
if (!globalThis.crypto) {
7785
throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");
7886
}
@@ -208,10 +216,16 @@
208216
return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
209217
}
210218

219+
const testCallExport = (a, b) => {
220+
this._inst.exports.testExport0();
221+
return this._inst.exports.testExport(a, b);
222+
}
223+
211224
const timeOrigin = Date.now() - performance.now();
212225
this.importObject = {
213226
_gotest: {
214227
add: (a, b) => a + b,
228+
callExport: testCallExport,
215229
},
216230
gojs: {
217231
// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)

web/src/workers/go/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { StartupParams, GoExecutor, WriteListener } from './types'
44

55
const WORKER_START_TIMEOUT = 30 * 1000
66

7-
type WriteHandler = (data: ArrayBuffer, isStderr: boolean) => void
7+
type WriteHandler = (data: ArrayBufferLike, isStderr: boolean) => void
88

99
interface SyncStdio {
1010
stdout: WriteListener

web/src/workers/go/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type WriteListener = (data: ArrayBuffer) => void
1+
export type WriteListener = (data: ArrayBufferLike) => void
22

33
export interface Stdio {
44
stdout: WriteListener

0 commit comments

Comments
 (0)