-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kadai3 2 n kumaya #61
base: master
Are you sure you want to change the base?
Conversation
166c97c
to
ededca3
Compare
ededca3
to
0c6ce00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
だいぶよいかも!
テスト書きましょう!
``` | ||
go run main.go [ターゲットURL] | ||
``` | ||
対象URLをCPU数に応じて分割ダウンロードを行う。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なぜCPU数で分割するのでしょうか?
ダウンロードはCPU依存の処理ではないため、CPU数に分割するのが妥当かどうか怪しいです。
func NewClient(urlString string) (*Client, error) { | ||
var err error | ||
client := &Client{} | ||
client.URL, err = url.Parse(urlString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err の値はすぐにチェックしましょう(普通と違うことをやると、コードを読む人に普通ではないのかと思われてしまう
) | ||
|
||
type Client struct { | ||
URL *url.URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validであることを検証した後に値として持つのはとてもよいですね
return err | ||
} | ||
defer res.Body.Close() | ||
c.ContentLength, err = strconv.Atoi(res.Header["Content-Length"][0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Content-Length
って HEAD
の時は絶対あるんでしたっけ?(わすれた
return nil | ||
} | ||
|
||
func (c *Client) newRequest(ctx context.Context, index int) (*http.Request, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
他の人のコードだと Range の値を引数で持ち回りがちなんですが、このやり方のほうが僕は好きです。
README に詳細を記入してあります。
よろしくお願い致します。