Skip to content

Commit

Permalink
Remove unused slowReader
Browse files Browse the repository at this point in the history
  • Loading branch information
dhui committed Jan 20, 2018
1 parent 8cbdc28 commit bdb332a
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions util.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package migrate

import (
"bufio"
"fmt"
"io"
nurl "net/url"
"strings"
"time"
)

// MultiError holds multiple errors.
Expand Down Expand Up @@ -46,35 +43,6 @@ func suint(n int) uint {
return uint(n)
}

// newSlowReader turns an io.ReadCloser into a slow io.ReadCloser.
// Use this to simulate a slow internet connection.
func newSlowReader(r io.ReadCloser) io.ReadCloser {
return &slowReader{
rx: r,
reader: bufio.NewReader(r),
}
}

type slowReader struct {
rx io.ReadCloser
reader *bufio.Reader
}

func (b *slowReader) Read(p []byte) (n int, err error) {
time.Sleep(10 * time.Millisecond)
c, err := b.reader.ReadByte()
if err != nil {
return 0, err
} else {
copy(p, []byte{c})
return 1, nil
}
}

func (b *slowReader) Close() error {
return b.rx.Close()
}

var errNoScheme = fmt.Errorf("no scheme")

// schemeFromUrl returns the scheme from a URL string
Expand Down

0 comments on commit bdb332a

Please sign in to comment.