bytecodealliance / bytecodealliance/wasmtime-go
Add SetStdout SetStdin
- Dominant language
- Go
- Stars
- 913
- Forks
- 100
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
I saw that I cannot easily convert the string `path` in `SetStdoutFile(path string)` to the `io.ReadWriter` on wasmtime-go, so this is a suggestion to wasmtime.
`io.ReadWriter` is an interface which implemented by `os.File` and `bytes.Buffer`. With an `io.ReadWriter` as the parameter for WASI config, golang can operate its favor bytes without filesystem-level io, which means the WASI call will be more easy safe and stable.
```go
buf := bytes.NewBuffer(nil)
config := wasmtime.NewWasiConfig()
config.SetStdin(buf)
config.SetStdout(buf)
// then instaniate the wasi with the config
go func(){
b, err buf.ReadBytes('\n')
// handle this
}()
go instance.GetExport("_start").Func().Call()
// now intance request a stdin
buf.Write("continue exec")
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.