Files
wazero/examples/import-go/age-calculator_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

25 lines
446 B
Go

package age_calculator
import "os"
// Example_main ensures the following will work:
//
// go run age-calculator.go 2000
func Example_main() {
// Save the old os.Args and replace with our example input.
oldArgs := os.Args
_ = os.Setenv("CURRENT_YEAR", "2021")
os.Args = []string{"age-calculator", "2000"}
defer func() {
os.Args = oldArgs
_ = os.Unsetenv("CURRENT_YEAR")
}()
main()
// Output:
// println >> 21
// log_i32 >> 21
}