-
Notifications
You must be signed in to change notification settings - Fork 179
Kadai3 2 mizushima #68
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 mizushima #68
Conversation
その他 main.go テストの追加により仕様変更 picconvert/picconvert.go godocでの見栄えが少しでも良くなるようにコメント追加 picconvert_test.go TestGlobでのテストケース追加、testdataをコピーしないように変更 Makefile 各コマンドをgoのものに変更 等々
"golang.org/x/sync/errgroup" | ||
) | ||
|
||
//PDownloader is user-defined struct |
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.
細かい事ですが、コメントでPDownloaderはユーザ定義型としか言っていないので、他と見比べるとPDownloader自体の説明が入るのが適切なのではと思います。
kadai3-2/Mizushima/main.go
Outdated
|
||
// make a empty context | ||
ctxTimeout, cancelTimeout := context.WithTimeout(context.Background(), time.Duration(opts.Tm)*time.Second) | ||
defer cancelTimeout() |
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.
ループの中でdeferを書くのはループ分defer処理が行われることになり、このケースではurlが三つあったとして関数を抜けるときに三連続でcancelTimeoutが走るのがおそらく必要ではない(実害はないかもしれませんが)ので望ましくないかと思います。
url一つづの処理で関数を切るのが、deferも適切になりますし、後に os.OpenFileしているところでdefer out.Close()が書けてCloseの関数を色々なところで呼ばなくても良くなるので良いかと思います。
kadai3-2/Mizushima/main.go
Outdated
log.Fatalf("err: getheader.ResHeader: %s\n", err) | ||
} else if accept[0] != "bytes" || opts.Procs == 1 { | ||
isPara = false | ||
continue |
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.
ここのcontinueっておそらく間違いなのではと思います。isPara = falseを入れている意味もないかと思うので。
後続の方が増えてきたのでCloseします。 |
お手数をおかけ致しますが、レビュー頂けますと幸いです
課題3-2 分割ダウンローダを作ろう
コマンドラインオプション
インストール方法
使い方
※ URLは複数指定できます
※ ダウンロード先がRangeアクセスに対応していれば、go routineを使った並行ダウンロードを行い、そうでなければ1プロセスのダウンロードを行います
テストの方法
ディレクトリ構成
参考にしたもの
pget (goroutineを使ったダウンロード処理、コマンドラインオプションの処理等々)
gopherdojo/dojo3#50 (ctrl+cを押したときのキャンセル処理など)