Skip to content

Kadai2 happylifetaka #29

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
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

happylifetaka
Copy link

@happylifetaka happylifetaka commented Nov 18, 2018

io.ReaderとioWriterについて調べたところまでとリファクタリングしたところまでとなります。
テストコード完了したら追加で更新します。🙇
->11/19追加いたしました。

【TRY】io.Readerとio.Writer

io.Readerとio.Writerについて調べてみよう

標準パッケージでどのように使われているか

  • io.ReaderのReadやio.WriterのWriteを直接を隠蔽(ラッピング)して使われている。

io.Readerとio.Writerがあることでどういう利点があるのか具体例を挙げて考えてみる

  • データの読み書きを標準化(データの受け渡しの手続きを抽象化)してあるのでデータの受け渡しが容易。それをベースにした様々なものを作れる。具体的には「encoding/json、bufio.Reader、os.File、image、png、base64」など。
  • データを変換することなく同じバイトのまま受け渡すことができるので高速、メモリ効率もよい。例:S3からのレスポンスデータを読み込んで保存するのにioutil.ReadAllを使うよりio.Copy使うほうが高速とのデータあり。https://christina04.hatenablog.com/entry/2017/01/06/190000

1回目の宿題のテストを作成

  • テストのしやすさを考えてリファクタリングしてみる
      ライブラリ内での標準出力を排除などしテストしやすくしました。
  • テストのカバレッジを取ってみる
    go test -cover
    go test -coverprofile=cover.out
    go tool cover -html=cover.out -o cover.html

  上記でカバレッジレポートまで作成しました。
  画像エンコード関連のエラーとwalkのエラーのカバレッジをとることができずでした。

  • テーブル駆動テストを行う
      後付けでテーブルテストを書いたので駆動(?)か怪しいけれど作成しました。

  • テストヘルパーを作ってみる
      サブテストを書かないと実質機能しない(?)ため、(作業時間の関係で)保留中🙇‍♂️

@tenntenn tenntenn added the kadai2 課題2 label Nov 19, 2018
@happylifetaka happylifetaka changed the title [WIP]Kadai2-happylifetaka Kadai2 happylifetaka Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kadai2 課題2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants