Skip to content

Commit

Permalink
Merge pull request moby#49256 from thaJeztah/ioutils_even_cleaner
Browse files Browse the repository at this point in the history
pkg/ioutils: remove deprecated NopWriter, NopWriteCloser
  • Loading branch information
thaJeztah authored Jan 10, 2025
2 parents ecaccdd + ce8d3d1 commit c2617e2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
22 changes: 0 additions & 22 deletions pkg/ioutils/writers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,6 @@ import (
"sync/atomic"
)

// NopWriter represents a type which write operation is nop.
//
// Deprecated: use [io.Discard] instead. This type will be removed in the next release.
type NopWriter struct{}

func (*NopWriter) Write(buf []byte) (int, error) {
return len(buf), nil
}

type nopWriteCloser struct {
io.Writer
}

func (w *nopWriteCloser) Close() error { return nil }

// NopWriteCloser returns a nopWriteCloser.
//
// Deprecated: This function is no longer used and will be removed in the next release.
func NopWriteCloser(w io.Writer) io.WriteCloser {
return &nopWriteCloser{w}
}

type writeCloserWrapper struct {
io.Writer
closer func() error
Expand Down
19 changes: 0 additions & 19 deletions pkg/ioutils/writers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,3 @@ func TestWriteCloserWrapperClose(t *testing.T) {
t.Fatalf("writeCloserWrapper should have call the anonymous function.")
}
}

func TestNopWriteCloser(t *testing.T) {
writer := bytes.NewBuffer([]byte{})
wrapper := NopWriteCloser(writer)
if err := wrapper.Close(); err != nil {
t.Fatal("NopWriteCloser always return nil on Close.")
}
}

func TestNopWriter(t *testing.T) {
nw := &NopWriter{}
l, err := nw.Write([]byte{'c'})
if err != nil {
t.Fatal(err)
}
if l != 1 {
t.Fatalf("Expected 1 got %d", l)
}
}

0 comments on commit c2617e2

Please sign in to comment.