-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
29 lines (23 loc) · 822 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<html>
<head><title>Go and TypeScript</title></head>
<body style="overflow: hidden;">
<h1>Hello World!</h1>
<p style="font-size: 40px;" id="sum"></span>
<!-- Step 1: export Gots to window object -->
<script src="https://cdn.jsdelivr.net/npm/ts2go@1.0.0/ts2go.js"></script>
<script>
function rand() {
return Math.floor(Math.random() * 100);
}
async function main() {
// Step 2: create a rpc client
const api = await Gots.getapi()
// Step 3: call remote go function: add
let a = rand(), b = rand();
document.getElementById("sum").innerText = a + " + " + b + " = " + await api.add(a, b)
}
main()
</script>
</body>
</html>