Skip to content

Commit a8b630b

Browse files
committed
Update dependency
1 parent 10599c8 commit a8b630b

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

daze.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,24 +1128,6 @@ func OpenFile(name string) (io.ReadCloser, error) {
11281128
return os.Open(name)
11291129
}
11301130

1131-
// The PrettyReader struct represents a custom reader that keeps track of read bytes and prints progress.
1132-
type PrettyReader struct {
1133-
E uint64 // Total number of bytes read so far
1134-
F uint64 // Total capacity of the input stream
1135-
R io.Reader // The underlying reader that this object wraps around
1136-
}
1137-
1138-
// The Read method reads data from the wrapped reader and prints progress updates.
1139-
func (r *PrettyReader) Read(p []byte) (int, error) {
1140-
if r.E == 0 {
1141-
pretty.PrintProgress(0)
1142-
}
1143-
n, err := r.R.Read(p)
1144-
r.E += uint64(n)
1145-
pretty.PrintProgress(float64(r.E) / float64(r.F))
1146-
return n, err
1147-
}
1148-
11491131
// RandomReader is a simple random number generator. Note that it is not cryptographically secure, but for daze, the
11501132
// randomness it provides is enough.
11511133
type RandomReader struct{}
@@ -1226,12 +1208,8 @@ func LoadApnic() map[string][]*net.IPNet {
12261208
url := "http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest"
12271209
log.Println("main: load apnic data from", url)
12281210
rep := doa.Try(http.Get(url))
1229-
f := &ReadWriteCloser{
1230-
Reader: &PrettyReader{0, uint64(rep.ContentLength), rep.Body},
1231-
Writer: nil,
1232-
Closer: rep.Body,
1233-
}
1234-
defer f.Close()
1211+
defer rep.Body.Close()
1212+
f := io.TeeReader(rep.Body, pretty.NewProgressWriter(rep.ContentLength))
12351213
r := map[string][]*net.IPNet{}
12361214
s := bufio.NewScanner(f)
12371215
for s.Scan() {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/libraries/daze
22

33
go 1.25.0
44

5-
require github.com/libraries/go v1.0.1
5+
require github.com/libraries/go v1.0.4

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ github.com/libraries/go v1.0.0 h1:haBcspBOvFO3J52zzRJP/6UV12WqOclxf6x1fEAWuBg=
22
github.com/libraries/go v1.0.0/go.mod h1:gDswTQfQ6h3VYCnUvrPEOPsRWYpDiNhO4ervTpYi41c=
33
github.com/libraries/go v1.0.1 h1:BMwbQzwht9N8dr56HigeJzTFQsffde2+WT+CzXL3NKw=
44
github.com/libraries/go v1.0.1/go.mod h1:gDswTQfQ6h3VYCnUvrPEOPsRWYpDiNhO4ervTpYi41c=
5+
github.com/libraries/go v1.0.3 h1:9akN9Ue5eO/x5dOrsoNFPdk6/a6SCcs3aK4k8FoAGeg=
6+
github.com/libraries/go v1.0.3/go.mod h1:gDswTQfQ6h3VYCnUvrPEOPsRWYpDiNhO4ervTpYi41c=
7+
github.com/libraries/go v1.0.4 h1:ajy5Alxarb9vde9OwTMKqcvfFuVlYtWXcLjyKorWKQc=
8+
github.com/libraries/go v1.0.4/go.mod h1:gDswTQfQ6h3VYCnUvrPEOPsRWYpDiNhO4ervTpYi41c=

0 commit comments

Comments
 (0)