Kadai2 shinta#17
Open
ShintaNakama wants to merge 14 commits intomasterfrom
Open
Conversation
tenntenn
reviewed
Sep 18, 2019
| allowExtList := []string{"jpg", "jpeg", "png", "gif"} | ||
| allowExtMap := map[string]bool{} | ||
| for _, ext := range allowExtList { | ||
| allowExtMap[ext] = true |
Member
There was a problem hiding this comment.
これで良さそうです。
allowExtMap := map[string]bool{
"jpg": true,
"jpeg": true,
"png": true,
"gif": true,
}
tenntenn
reviewed
Sep 18, 2019
| return nil | ||
| } | ||
|
|
||
| func (a *arg) convertExt() { |
tenntenn
reviewed
Sep 18, 2019
| } | ||
|
|
||
| // createImgStrunct は、imageFile structを生成し、返します。 | ||
| func createImgStruct(path string) (image imageFile) { |
Member
There was a problem hiding this comment.
型で分かるので名前付き戻り値にしない。
特に理由がない場合は、戻り値もポインタにする。
tenntenn
reviewed
Sep 18, 2019
| */ | ||
| func convertExec(path, afterExt string) error { | ||
| img := createImgStruct(path) | ||
| targetImg, err := os.Open(img.path + "/" + img.base + img.ext) |
tenntenn
reviewed
Sep 18, 2019
| if err != nil { | ||
| return err | ||
| } | ||
| outputImg, err := os.Create((img.path + "/" + img.base + afterExt)) |
tenntenn
reviewed
Sep 18, 2019
| default: | ||
| png.Encode(outputImg, readImg) | ||
| } | ||
| err = targetImg.Close() |
tenntenn
reviewed
Sep 18, 2019
| func TestValid(t *testing.T) { | ||
| t.Helper() | ||
| for _, arg := range exampleArgs { | ||
| t.Run(arg.testCase, func(t *testing.T) { |
tenntenn
reviewed
Sep 18, 2019
| } | ||
|
|
||
| func TestValid(t *testing.T) { | ||
| t.Helper() |
tenntenn
reviewed
Sep 18, 2019
| afterExt string | ||
| } | ||
|
|
||
| var exampleArgs = []exampleArg{ |
tenntenn
reviewed
Sep 18, 2019
| p := flag.String("p", "jpeg", "変換前拡張子") | ||
| a := flag.String("a", "png", "変換後拡張子") | ||
| if flag.Parse(); flag.Parsed() { | ||
| dir, preExt, afterExt = *d, *p, *a |
Member
There was a problem hiding this comment.
こうするなら、flag.StringVarでdirとかのポインタを渡した方が良さそう
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
課題2
io.Readerとio.Writerについて調べてみよう
標準パッケージでどのように使われているか
io.Readerとio.Writerがあることでどういう利点があるのか具体例を挙げて考えてみる
test