Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tee ¶
type Tee struct {
OrigStdout *os.File
OrigStderr *os.File
Stdout *os.File
Stderr *os.File
TeeFile *os.File
// contains filtered or unexported fields
}
func NewTee ¶
Example ¶
tee, err := NewTee("tee.out")
if err != nil {
fmt.Printf("ERROR: tee: %s\n", err)
return
}
// you can write headers, dates etc just to the
// tee file if necessary
fmt.Fprintf(tee.OrigStdout, "write to stdout but not tee file\n")
fmt.Fprintf(tee.TeeFile, "test to tee file\n")
fmt.Fprintf(os.Stderr, "test to stderr\n")
fmt.Printf("test to stdout\n")
tee.Close()
fmt.Printf("more to stdout\n")
teed, _ := ioutil.ReadFile("tee.out")
fmt.Printf("teed output:\n%s", teed)
Output: write to stdout but not tee file test to stdout more to stdout teed output: test to tee file test to stderr test to stdout
Click to show internal directories.
Click to hide internal directories.