课程: Go Essentials: Concurrency, Connectivity, and High-Performance Apps

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Challenge: Download size

Challenge: Download size

(upbeat music) - I want you to calculate the total download size for a given month concurrently. For each month we have two files, green and yellow, for example, this is the one for March 20200, green and then yellow. What you're going to do is you're going to issue an HTP head request, which here I'm doing using the CRL commander client with a dashi. And the head request is going to return the size of the file in the header without returning the whole file. The current code has a serial algorithm that does that. We have the URL template and the colors and a function to get the download size from the URL. It creates a new request. Then do a head request on this request checks the status code and finally convert the content length header to a number. And in the domain, we start the time initialize the size to zero and then for every month and for every color we create the URL for that month and that color, print it…

内容