Skip to content

Commit 67273c0

Browse files
committed
multi: use Go 1.19.7
1 parent 1f5aaf6 commit 67273c0

File tree

5 files changed

+21
-103
lines changed

5 files changed

+21
-103
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
# go needs absolute directories, using the $HOME variable doesn't work here.
1717
GOCACHE: /home/runner/work/go/pkg/build
1818
GOPATH: /home/runner/work/go
19-
GO_VERSION: 1.18.x
19+
GO_VERSION: 1.19.7
2020

2121
jobs:
2222
########################

cmd/wasm-client/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@ replace github.com/lightninglabs/lightning-node-connect => ../../
181181

182182
replace github.com/lightninglabs/lightning-node-connect/hashmailrpc => ../../hashmailrpc
183183

184-
go 1.18
184+
go 1.19

example/wasm_exec.js

Lines changed: 17 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,18 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
(() => {
6-
// Map multiple JavaScript environments to a single common API,
7-
// preferring web standards over Node.js API.
8-
//
9-
// Environments considered:
10-
// - Browsers
11-
// - Node.js
12-
// - Electron
13-
// - Parcel
14-
// - Webpack
15-
16-
if (typeof global !== 'undefined') {
17-
// global already exists
18-
} else if (typeof window !== 'undefined') {
19-
window.global = window;
20-
} else if (typeof self !== 'undefined') {
21-
self.global = self;
22-
} else {
23-
throw new Error('cannot export Go (neither global, window nor self is defined)');
24-
}
25-
26-
if (!global.require && typeof require !== 'undefined') {
27-
global.require = require;
28-
}
29-
30-
if (!global.fs && global.require) {
31-
const fs = require('fs');
32-
if (typeof fs === 'object' && fs !== null && Object.keys(fs).length !== 0) {
33-
global.fs = fs;
34-
}
35-
}
5+
'use strict';
366

7+
(() => {
378
const enosys = () => {
389
const err = new Error('not implemented');
3910
err.code = 'ENOSYS';
4011
return err;
4112
};
4213

43-
if (!global.fs) {
14+
if (!globalThis.fs) {
4415
let outputBuf = '';
45-
global.fs = {
16+
globalThis.fs = {
4617
constants: {
4718
O_WRONLY: -1,
4819
O_RDWR: -1,
@@ -140,8 +111,8 @@
140111
};
141112
}
142113

143-
if (!global.process) {
144-
global.process = {
114+
if (!globalThis.process) {
115+
globalThis.process = {
145116
getuid() {
146117
return -1;
147118
},
@@ -171,47 +142,26 @@
171142
}
172143
}
173144

174-
if (!global.crypto && global.require) {
175-
const nodeCrypto = require('crypto');
176-
global.crypto = {
177-
getRandomValues(b) {
178-
nodeCrypto.randomFillSync(b);
179-
},
180-
};
181-
}
182-
if (!global.crypto) {
183-
throw new Error('global.crypto is not available, polyfill required (getRandomValues only)');
145+
if (!globalThis.crypto) {
146+
throw new Error('globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)');
184147
}
185148

186-
if (!global.performance) {
187-
global.performance = {
188-
now() {
189-
const [sec, nsec] = process.hrtime();
190-
return sec * 1000 + nsec / 1000000;
191-
},
192-
};
149+
if (!globalThis.performance) {
150+
throw new Error('globalThis.performance is not available, polyfill required (performance.now only)');
193151
}
194152

195-
if (!global.TextEncoder && global.require) {
196-
global.TextEncoder = require('util').TextEncoder;
197-
}
198-
if (!global.TextEncoder) {
199-
throw new Error('global.TextEncoder is not available, polyfill required');
153+
if (!globalThis.TextEncoder) {
154+
throw new Error('globalThis.TextEncoder is not available, polyfill required');
200155
}
201156

202-
if (!global.TextDecoder && global.require) {
203-
global.TextDecoder = require('util').TextDecoder;
157+
if (!globalThis.TextDecoder) {
158+
throw new Error('globalThis.TextDecoder is not available, polyfill required');
204159
}
205-
if (!global.TextDecoder) {
206-
throw new Error('global.TextDecoder is not available, polyfill required');
207-
}
208-
209-
// End of polyfills for common API.
210160

211161
const encoder = new TextEncoder('utf-8');
212162
const decoder = new TextDecoder('utf-8');
213163

214-
global.Go = class {
164+
globalThis.Go = class {
215165
constructor() {
216166
this.argv = ['js'];
217167
this.env = {};
@@ -586,7 +536,7 @@
586536
null,
587537
true,
588538
false,
589-
global,
539+
globalThis,
590540
this,
591541
];
592542
this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
@@ -595,7 +545,7 @@
595545
[null, 2],
596546
[true, 3],
597547
[false, 4],
598-
[global, 5],
548+
[globalThis, 5],
599549
[this, 6],
600550
]);
601551
this._idPool = []; // unused ids that have been garbage collected
@@ -670,36 +620,4 @@
670620
};
671621
}
672622
}
673-
674-
if (
675-
typeof module !== 'undefined' &&
676-
global.require &&
677-
global.require.main === module &&
678-
global.process &&
679-
global.process.versions &&
680-
!global.process.versions.electron
681-
) {
682-
if (process.argv.length < 3) {
683-
console.error('usage: go_js_wasm_exec [wasm binary] [arguments]');
684-
process.exit(1);
685-
}
686-
687-
const go = new Go();
688-
go.argv = process.argv.slice(2);
689-
go.env = Object.assign({TMPDIR: require('os').tmpdir()}, process.env);
690-
go.exit = process.exit;
691-
WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
692-
process.on('exit', (code) => { // Node.js exits if no event handler is pending
693-
if (code === 0 && !go.exited) {
694-
// deadlock, make Go print error and stack traces
695-
go._pendingEvent = {id: 0};
696-
go._resume();
697-
}
698-
});
699-
return go.run(result.instance);
700-
}).catch((err) => {
701-
console.error(err);
702-
process.exit(1);
703-
});
704-
}
705623
})();

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,4 @@ require (
166166
sigs.k8s.io/yaml v1.2.0 // indirect
167167
)
168168

169-
go 1.18
169+
go 1.19

mobile/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@ require (
174174

175175
replace github.com/lightninglabs/lightning-node-connect => ../
176176

177-
go 1.18
177+
go 1.19

0 commit comments

Comments
 (0)