Skip to content

segment-boneyard/go-dup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dup

Build Status

Dup(fd, name) returns a RW pipe for the given fd. For example this allows you to proxy stdio, logging to your preferred logger and then re-write to the original stdio stream.

Example

r, w, err := Dup(1, "stdout")
check(err)

go func() {
  fmt.Printf("testing\n")
}()

buf := bufio.NewReader(r)
line, err := buf.ReadString('\n')
check(err)

fmt.Fprintf(w, line)

License

MIT