tinygo/testdata/stdlib.go
Ayke van Laethem 75298bb84b os: implement process related functions
This commit implements various process related functions like
os.Getuid() and os.Getpid(). It also implements or improves this support
in the syscall package if it isn't available yet.
2021-06-25 16:14:47 +02:00

34 строки
720 Б
Go

package main
import (
"fmt"
"math/rand"
"os"
"strings"
"syscall"
)
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.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)
}