mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-17 18:06:15 -05:00
27 lines
400 B
Go
27 lines
400 B
Go
package io
|
|
|
|
import (
|
|
"github.com/v2ray/v2ray-core/common/log"
|
|
)
|
|
|
|
func Pipe(reader Reader, writer Writer) error {
|
|
for {
|
|
buffer, err := reader.Read()
|
|
if err != nil {
|
|
log.Debug("IO: Pipe exits as ", err)
|
|
return err
|
|
}
|
|
|
|
if buffer.IsEmpty() {
|
|
buffer.Release()
|
|
continue
|
|
}
|
|
|
|
err = writer.Write(buffer)
|
|
if err != nil {
|
|
log.Debug("IO: Pipe exits as ", err)
|
|
return err
|
|
}
|
|
}
|
|
}
|