Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Kadai3 2 misonog #53

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

Open
misonog wants to merge 38 commits into gopherdojo:master
base: master
Choose a base branch
Loading
from misonog:kadai3-2-misonog
Open

Conversation

@misonog
Copy link

@misonog misonog commented Apr 30, 2021

分割ダウンローダ

仕様

  • 分割ダウンロードを行う
    • Range アクセスを用いる
    • いくつかのゴルーチンでダウンロードしてマージする
    • エラー処理を工夫する
      • golang.org/x/sync/errgourp パッケージなどを使ってみる
    • キャンセルが発生した場合の実装を行う

オプション

オプション 内容 デフォルト
-d ファイルをダウンロードするディレクトリ $PWD
-t タイムアウトするまでの時間(秒) 10

利用方法

setup

$ make # テスト & ビルド

ダウンロードコマンドの例

$ ./pdownload https://blog.golang.org/gopher/header.jpg
$ # ディレクトリとタイムアウトまでの時間の指定
$ ./pdownload -d testdata/ -t 30 https://blog.golang.org/gopher/header.jpg

ディレクトリ構造

.
├── Makefile
├── README.md
├── go.mod
├── go.sum
├── main.go
├── pdownload
├── pdownload.go
├── pdownload_test.go
├── requests.go
├── requests_test.go
├── termination
│ ├── termination.go
│ └── termination_test.go
├── testdata
│ ├── header.jpg
│ └── test_download
│ └── header.jpg
└── util.go

参考

Code-Hex/pgetgopherdojo/dojo3#50を参考にさせていただきました。

メモ

  • net/http/httptestをテストに活用してみました
  • エラーチェックなどでご指摘あるかもしれませんが、レビュー宜しくお願いいたします

misonog added 23 commits April 9, 2021 08:41
@tenntenn tenntenn added the 課題3-2 Good for newcomers label Apr 30, 2021
@tenntenn tenntenn self-assigned this Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tenntenn tenntenn tenntenn left review comments

Labels

課題3-2 Good for newcomers

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /