Skip to content

Commit

Permalink
Merge pull request #23 from go-zoox/fix/config-onporogress-need-be-a-…
Browse files Browse the repository at this point in the history
…func

fix: config onporogress need be a func instead of point to func
  • Loading branch information
whatwewant committed Aug 20, 2023
2 parents f2dc1bb + 629698e commit a899cb1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Config struct {
//
Context context.Context
//
OnProgress *func(percent int64, current, total int64)
OnProgress func(percent int64, current, total int64)
//
BasicAuth BasicAuth
//
Expand Down
2 changes: 1 addition & 1 deletion execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (f *Fetch) Execute() (*Response, error) {
progress := &Progress{
Total: resp.ContentLength,
Current: 0,
Reporter: *f.config.OnProgress,
Reporter: f.config.OnProgress,
}

_, err = io.Copy(io.MultiWriter(file, progress), reader)
Expand Down
2 changes: 1 addition & 1 deletion fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (f *Fetch) SetDownloadFilePath(filepath string) *Fetch {

// SetProgressCallback sets the progress callback
func (f *Fetch) SetProgressCallback(callback func(percent int64, current, total int64)) *Fetch {
f.config.OnProgress = &callback
f.config.OnProgress = callback
return f
}

Expand Down

0 comments on commit a899cb1

Please sign in to comment.