Files
wazero/examples/wasi/cat_test.go
Crypt Keeper 106f96b066 Adds import-go example (#466)
This shows how to define, export and import functions written in Go.

Fixes #464

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-04-15 09:31:52 +08:00

20 lines
343 B
Go

package wasi_example
import "os"
// Example_main ensures the following will work:
//
// go run cat.go ./test.txt
func Example_main() {
// Save the old os.Args and replace with our example input.
oldArgs := os.Args
os.Args = []string{"cat", "./test.txt"}
defer func() { os.Args = oldArgs }()
main()
// Output:
// hello filesystem
}