1
2
3
4
5 package main
6
7 import (
8 "fmt"
9 "io"
10 "log"
11 "os"
12 )
13
14 func main() {
15 f, err := os.OpenFile(os.Getenv("TEST_OUTPUT"), os.O_CREATE|os.O_RDWR, 0600)
16 if err != nil {
17 log.Fatalf("os.Open failed: %s", err)
18 }
19 defer f.Close()
20 b, err := io.ReadAll(os.Stdin)
21 if err != nil {
22 log.Fatalf("io.ReadAll(os.Stdin) failed: %s", err)
23 }
24 if len(b) != 0 {
25 log.Fatalf("io.ReadAll(os.Stdin) returned non-nil: %x", b)
26 }
27 fmt.Fprintf(os.Stdout, "stdout\n")
28 fmt.Fprintf(os.Stderr, "stderr\n")
29 }
30
View as plain text