Skip to content

rlaskowski/simpleclient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d2ad07c · Jun 10, 2021

History

38 Commits
Jun 7, 2021
Jun 8, 2021
May 31, 2021
Jun 10, 2021
May 23, 2021
Jun 2, 2021

Repository files navigation

simpleclient

Simple http client to help downloading resources

Install

go get github.com/rlaskowski/simpleclient

Example

This example show how to download file from url

fs := simpleclient.NewFileStream("/home/examplepath")

url := "http://ipv4.download.thinkbroadband.com/200MB.zip"

_, err := fs.Download(url, func(streaminfo simpleclient.StreamInfo) error {
  if streaminfo.WrittenBytes > 0 {
		log.Printf("Written: %.2f percent", streaminfo.ProgressInPercent())
	}

	if streaminfo.Complete {
		log.Print("Complete")
	}

	return nil
})

if err != nil {
    return err
}