-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
254 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package request | ||
|
||
import "io" | ||
|
||
// ProgressBarMaxSetter is an interface that allows setting the maximum value of a progress bar | ||
type ProgressBarMaxSetter interface { | ||
SetMax64(int64) | ||
} | ||
|
||
// ProgressBarMaxChanger is an interface that allows setting the maximum value of a progress bar | ||
// | ||
// This interface allows packages such as "/github.com/schollz/progressbar/v3" to be used as progress bars | ||
type ProgressBarMaxChanger interface { | ||
ChangeMax64(int64) | ||
} | ||
|
||
type progressReader struct { | ||
io.Reader | ||
Progress io.Writer | ||
} | ||
|
||
func (reader *progressReader) Read(p []byte) (n int, err error) { | ||
n, err = reader.Reader.Read(p) | ||
_, _ = reader.Progress.Write(p[:n]) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters