Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Kadai3 2 n kumaya #61

wants to merge 1 commit into from

Conversation

nKumaya
Copy link

@nKumaya nKumaya commented Sep 10, 2018

README に詳細を記入してあります。
よろしくお願い致します。

@nKumaya nKumaya force-pushed the kadai3-2-nKumaya branch 2 times, most recently from 166c97c to ededca3 Compare September 10, 2018 11:43
Copy link

@vvakame vvakame left a 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数に応じて分割ダウンロードを行う。
Copy link

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)
Copy link

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
Copy link

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])
Copy link

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) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

他の人のコードだと Range の値を引数で持ち回りがちなんですが、このやり方のほうが僕は好きです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants