From 62e996b9bebad22ee885c6ecd62a820f5daf4186 Mon Sep 17 00:00:00 2001 From: syumai Date: Sat, 22 Feb 2025 23:23:43 +0900 Subject: [PATCH] update wasm_exec_go.js for Go 1.24 --- cmd/workers-assets-gen/assets/wasm_exec_go.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/workers-assets-gen/assets/wasm_exec_go.js b/cmd/workers-assets-gen/assets/wasm_exec_go.js index 8931314..99585e0 100644 --- a/cmd/workers-assets-gen/assets/wasm_exec_go.js +++ b/cmd/workers-assets-gen/assets/wasm_exec_go.js @@ -14,7 +14,7 @@ if (!globalThis.fs) { let outputBuf = ""; globalThis.fs = { - constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused + constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_DIRECTORY: -1 }, // unused writeSync(fd, buf) { outputBuf += decoder.decode(buf); const nl = outputBuf.lastIndexOf("\n"); @@ -73,6 +73,14 @@ } } + if (!globalThis.path) { + globalThis.path = { + resolve(...pathSegments) { + return pathSegments.join("/"); + } + } + } + if (!globalThis.crypto) { throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)"); } @@ -208,10 +216,16 @@ return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len)); } + const testCallExport = (a, b) => { + this._inst.exports.testExport0(); + return this._inst.exports.testExport(a, b); + } + const timeOrigin = Date.now() - performance.now(); this.importObject = { _gotest: { add: (a, b) => a + b, + callExport: testCallExport, }, gojs: { // Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)