Files
tinygo/testdata/stdlib.go
T
Ayke van Laethem 020cca8c3c wasm: add more stubbed file operations
This fixes issue #5037. A few more wasip1 syscalls needed to be present,
and in particular fd_prestat_get needed to return EBADF on invalid file
descriptors.
2026-04-17 16:02:45 +01:00

41 lines
885 B
Go

package main
import (
"fmt"
"math/rand"
"os"
"strings"
"syscall"
"time"
)
func main() {
// package os, fmt
fmt.Println("stdin: ", os.Stdin.Name())
fmt.Println("stdout:", os.Stdout.Name())
fmt.Println("stderr:", os.Stderr.Name())
// Package syscall, this mostly checks whether the calls don't trigger an error.
syscall.Getuid()
syscall.Geteuid()
syscall.Getgid()
syscall.Getegid()
syscall.Getpid()
syscall.Getppid()
// package math/rand
fmt.Println("pseudorandom number:", rand.New(rand.NewSource(1)).Int31())
// package strings
fmt.Println("strings.IndexByte:", strings.IndexByte("asdf", 'd'))
fmt.Println("strings.Replace:", strings.Replace("An example string", " ", "-", -1))
// package time
time.Sleep(time.Millisecond)
time.Sleep(-1) // negative sleep should return immediately
time.LoadLocation("UTC")
// Exit the program normally.
os.Exit(0)
}