...

Source file src/runtime/testdata/testfds/main.go

Documentation: runtime/testdata/testfds

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     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