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>
20 lines
343 B
Go
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
|
|
}
|