tinygo/testdata/stdlib.go
Ayke van Laethem 6dd5666ed1 wasm: use WASI ABI for exit function
This improves compatibility between the regular browser target
(-target=wasm) and the WASI target (-target=wasi). Specifically, it
allows running WASI tests like this:

    tinygo test -target=wasi encoding/base32
2021-04-15 08:45:08 +02:00

25 строки
515 Б
Go

package main
import (
"fmt"
"math/rand"
"os"
"strings"
)
func main() {
// package os, fmt
fmt.Println("stdin: ", os.Stdin.Name())
fmt.Println("stdout:", os.Stdout.Name())
fmt.Println("stderr:", os.Stderr.Name())
// package math/rand
fmt.Println("pseudorandom number:", rand.Int31())
// package strings
fmt.Println("strings.IndexByte:", strings.IndexByte("asdf", 'd'))
fmt.Println("strings.Replace:", strings.Replace("An example string", " ", "-", -1))
// Exit the program normally.
os.Exit(0)
}