-
Notifications
You must be signed in to change notification settings - Fork 0
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
hiroygo / 課題1 #7
base: master
Are you sure you want to change the base?
Conversation
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.
見ました!
// Unknown 不明な画像 | ||
Unknown ImageType = "unknown" | ||
// Jpeg Jpeg 画像 | ||
Jpeg ImageType = "jpg" |
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.
略語はすべて大文字または小文字で
// ToImageType 文字列を ImageType に変換する | ||
// e.g. "jpg" => Jpeg | ||
func ToImageType(s string) ImageType { | ||
switch s { |
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.
strings.ToLowerを使っても良いかもしれないですね。
https://golang.org/pkg/strings/#ToLower
} | ||
|
||
func imageTypeFromFileName(name string) ImageType { | ||
extWithoutDot := strings.TrimLeft(filepath.Ext(name), ".") |
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.
このくらいであればスライス演算でもいいかもしれないです。
|
||
func imageTypeFromFileName(name string) ImageType { | ||
extWithoutDot := strings.TrimLeft(filepath.Ext(name), ".") | ||
return ToImageType(strings.ToLower(extWithoutDot)) |
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.
ここでToLowerするより、ToImageTypeの内部でやったほうが使う側の手間が省けます。
var pathes []string | ||
err := filepath.Walk(dir, func(visitPath string, f os.FileInfo, err error) error { | ||
if err != nil { | ||
return fmt.Errorf("WalkFunc error, %w", err) |
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.
👍
) | ||
|
||
func parseArgs() (dir string, in, out imgconv.ImageType, err error) { | ||
d := flag.String("d", "./", "変換の対象となる画像が格納されたディレクトリパス") |
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.
/
は含めずに.
で良いと思います。Windowsは\
なので。
dir, inType, outType, err := parseArgs() | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return |
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.
os.Exitで0以外で終了したほうが良いでしょう。
課題1のPRになります。
お忙しいところ、すみませんが
レビューをよろしくお願いいたします。