mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
0d646d8e95
Not all features work yet, but allow it to compile with this Go version.
40 lines
859 B
Go
40 lines
859 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
|
|
|
|
// Exit the program normally.
|
|
os.Exit(0)
|
|
}
|