Skip to content

Commit ba20057

Browse files
authored
Merge pull request #12 from SimonBaeumer/refactoring
Refactor multiplexed_writer
2 parents 4de84e4 + c19da6f commit ba20057

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

multiplexed_writer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import (
66
)
77

88
// NewMultiplexedWriter returns a new multiplexer
9-
func NewMultiplexedWriter(outputs ...io.Writer) *MultiplexedWriter {
10-
return &MultiplexedWriter{Outputs: outputs}
9+
func NewMultiplexedWriter(writers ...io.Writer) *MultiplexedWriter {
10+
return &MultiplexedWriter{Writers: writers}
1111
}
1212

1313
// MultiplexedWriter writes to multiple writers at once
1414
type MultiplexedWriter struct {
15-
Outputs []io.Writer
15+
Writers []io.Writer
1616
}
1717

1818
// Write writes the given bytes. If one write fails it returns the error
1919
// and bytes of the failed write operation
2020
func (w MultiplexedWriter) Write(p []byte) (n int, err error) {
21-
for _, o := range w.Outputs {
21+
for _, o := range w.Writers {
2222
n, err = o.Write(p)
2323
if err != nil {
2424
return 0, fmt.Errorf("Error in writer: %s", err.Error())

multiplexed_writer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
func TestMultiplexedWriter(t *testing.T) {
1212
writer01 := bytes.Buffer{}
1313
writer02 := bytes.Buffer{}
14-
// Test another io.Writer interface type
14+
// Test another io.Writers interface type
1515
r, w, _ := os.Pipe()
1616

1717
writer := NewMultiplexedWriter(&writer01, &writer02, w)

0 commit comments

Comments
 (0)