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 11
2- build :
3- GOOS=wasip1 GOARCH=wasm go build -o golangcheck.wasm .
2+ build : golangcheck.tgz
43.PHONY : build
54
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+
611clean :
712 rm -f golangcheck.wasm
13+ rm -f golangcheck.tgz
814.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