Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/go-dup
Dup an fd for a RW pipe
https://github.com/segment-boneyard/go-dup
Last synced: about 5 hours ago
JSON representation
Dup an fd for a RW pipe
- Host: GitHub
- URL: https://github.com/segment-boneyard/go-dup
- Owner: segment-boneyard
- Created: 2014-07-24T17:19:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-09T04:32:57.000Z (about 10 years ago)
- Last Synced: 2024-04-09T16:31:04.541Z (7 months ago)
- Language: Go
- Size: 137 KB
- Stars: 10
- Watchers: 44
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# Dup
[![Build Status](https://travis-ci.org/segmentio/go-dup.svg?branch=master)](https://travis-ci.org/segmentio/go-dup)
`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
```go
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