File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1
- golangcheck.wasm
1
+ golangcheck.wasm
2
+ golangcheck.tgz
Original file line number Diff line number Diff line change 1
1
2
- build :
3
- GOOS=wasip1 GOARCH=wasm go build -o golangcheck.wasm .
2
+ build : golangcheck.tgz
4
3
.PHONY : build
5
4
5
+ golangcheck.tgz : golangcheck.wasm init.js
6
+ tar -czf golangcheck.tgz golangcheck.wasm init.js
7
+
8
+ golangcheck.wasm : main.go
9
+ GOOS=wasip1 GOARCH=wasm go build -o golangcheck.wasm .
10
+
6
11
clean :
7
12
rm -f golangcheck.wasm
13
+ rm -f golangcheck.tgz
8
14
.PHONY : clean
Original file line number Diff line number Diff line change
1
+ ( async ( ) => {
2
+ // convert \n to \r\n since we have no line discipline in this setup
3
+ const transform = new TransformStream ( {
4
+ transform ( chunk , controller ) {
5
+ const text = new TextDecoder ( ) . decode ( chunk ) ;
6
+ const converted = text . replace ( / \n / g, '\r\n' ) ;
7
+ controller . enqueue ( new TextEncoder ( ) . encode ( converted ) ) ;
8
+ }
9
+ } ) ;
10
+
11
+ console . log ( "running golang init.js" ) ;
12
+ const w = window . wanix . instance ;
13
+ const tid = ( await w . readText ( "task/new/wasi" ) ) . trim ( ) ;
14
+ await w . writeFile ( `task/${ tid } /cmd` , "#bundle/golangcheck.wasm" ) ;
15
+ const stdout = await w . openReadable ( `task/${ tid } /fd/1` ) ;
16
+ const cons = await w . openWritable ( `#console/data1` ) ;
17
+ await w . writeFile ( `task/${ tid } /ctl` , "start" ) ;
18
+ stdout . pipeThrough ( transform ) . pipeTo ( cons ) ;
19
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments