
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
25 строки
515 Б
Go
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)
|
|
}
|