github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/testdata/stdlib.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "math/rand" 6 "os" 7 "strings" 8 "syscall" 9 "time" 10 ) 11 12 func main() { 13 // package os, fmt 14 fmt.Println("stdin: ", os.Stdin.Name()) 15 fmt.Println("stdout:", os.Stdout.Name()) 16 fmt.Println("stderr:", os.Stderr.Name()) 17 18 // Package syscall, this mostly checks whether the calls don't trigger an error. 19 syscall.Getuid() 20 syscall.Geteuid() 21 syscall.Getgid() 22 syscall.Getegid() 23 syscall.Getpid() 24 syscall.Getppid() 25 26 // package math/rand 27 fmt.Println("pseudorandom number:", rand.New(rand.NewSource(1)).Int31()) 28 29 // package strings 30 fmt.Println("strings.IndexByte:", strings.IndexByte("asdf", 'd')) 31 fmt.Println("strings.Replace:", strings.Replace("An example string", " ", "-", -1)) 32 33 // package time 34 time.Sleep(time.Millisecond) 35 time.Sleep(-1) // negative sleep should return immediately 36 37 // Exit the program normally. 38 os.Exit(0) 39 }