Makes all examples and docs use Runtime.Close (#537)

This removes tedium in our examples and docs by using `Runtime.Close`
instead of tracking everything. Internal tests still track too much, but
anyway at least this stops suggesting others should do it.

This also changes our examples to use log.PanicXX so that the line
number goes into the console output.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2022-05-10 12:08:25 +08:00
committed by GitHub
parent 8dd797e108
commit 03bfa31928
17 changed files with 127 additions and 109 deletions

View File

@@ -27,7 +27,7 @@ func Example() {
(export "add" (func $add))
)`))
if err != nil {
log.Fatal(err)
log.Panicln(err)
}
defer mod.Close(ctx)
@@ -37,7 +37,7 @@ func Example() {
x, y := uint64(1), uint64(2)
results, err := add.Call(ctx, x, y)
if err != nil {
log.Fatal(err)
log.Panicln(err)
}
fmt.Printf("%s: %d + %d = %d\n", mod.Name(), x, y, results[0])