hashicorp / go-getter

Package for downloading things from a string URL using a variety of protocols.
Mozilla Public License 2.0
1.64k stars 230 forks source link

How to use progress tracker #353

Open cathex-ryan-deamer opened 2 years ago

cathex-ryan-deamer commented 2 years ago

Hi,

I'm pretty new to golang and I can't work out how to use the progress tracker. Would someone be able to give me an example?

Thanks,

Ryan

azr commented 2 years ago

👋🏼 Hello there,

depends on which branch. On the v2 branch, you pass an instance to the request, like in here:

https://github.com/hashicorp/go-getter/blob/331021918dba05d95846a0d03f117aeccf120ca1/cmd/go-getter/main.go#L48-L56

That progress bar is defined here:

https://github.com/hashicorp/go-getter/blob/7cc4779f849d8e78a529d195bb5ffef1007e05d1/cmd/go-getter/progress_tracking.go#L11-L15

This bar will show the progress on the terminal.


If you want to implement that progress bar, you have to implement this interface:

https://github.com/hashicorp/go-getter/blob/8c9292b8e0785df7d05e79deb029508cd59804b8/client_option_progress.go#L7-L26

Let me know if you have further questions ! :)