Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[WIP]kadai3 happylifetaka #44
base: master
Are you sure you want to change the base?
[WIP]kadai3 happylifetaka #44
Changes from 2 commits
7c0a055
3b21483
3f6677d
e9b286f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
連続する変数の型が同じ場合は省略可能です
(url, saveFilePath string, div int64)
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.
http.Header
にはGet(key string) (value string)
が実装されているので、forせずに確認することもできます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.
エラーのチェックをしてから
out
の変数を触ったほうが良いです理由は、エラーが帰ってきている時点でファイルが作成されているかどうかわからない(
out
がnilの可能性がある)ため、そのCloseは利用しないほうが良いです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.
io.Copyもエラーを返す可能性があるので、捨てないほうが良いです
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.
エラーは捨てないほうが良いです
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.
ioutil.ReadAllですべて読み込んでしまって、Writeするよりもio.Copyで扱った方が効率が良い場合が多いです
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.
場合によりますが、ここにおけるエラーは一つのファイルを消せないことでなく、消せなかったファイルが存在することだと思います
したがって、途中でエラーになった場合でもそのエラーを保存し、最後まで実行して、消せなかったファイル一覧としたほうが良いと思います