gotee

package module
v0.0.0-...-31c2251 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

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

func NewTee(filename string) (*Tee, error)
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

func (*Tee) Close

func (t *Tee) Close()

func (*Tee) Sync

func (t *Tee) Sync()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL