Files
wazero/examples/wasi/testdata/cat.go
Crypt Keeper 958ce19c0b Makes examples runnable and pares down list (#458)
This deduplicates examples, leaving only the most maintained or targeted
ones. Notably, this makes each runnable, avoiding test dependencies.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-04-13 16:03:50 +08:00

22 lines
463 B
Go

package main
import (
"io/ioutil"
"os"
)
// main is the same as wasi: "concatenate and print files."
func main() {
// Start at arg[1] because args[0] is the program name.
for i := 1; i < len(os.Args); i++ {
// Intentionally use ioutil.ReadFile instead of os.ReadFile for TinyGo.
bytes, err := ioutil.ReadFile(os.Args[i])
if err != nil {
os.Exit(1)
}
// Use write to avoid needing to worry about Windows newlines.
os.Stdout.Write(bytes)
}
}