Skip to content

Commit

Permalink
Replace -> slice
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaka0325 committed Jul 20, 2020
1 parent f5b7212 commit 2eea02e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions kadai2/tanaka0325/imgconv/cmd/imgconv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/gopherdojo/dojo8/kadai2/tanaka0325/imgconv"
)
Expand Down Expand Up @@ -81,7 +80,8 @@ func main() {
onExit(err)
}
} else {
fmt.Printf("%[1]s.%[2]s => %[1]s.%[3]s\n", path, from, param.ToExt)
e := len(param.Path) - len(param.FromExt)
fmt.Printf("%s => %s%s\n", path, path[:e], to)
}
}
}
Expand Down Expand Up @@ -120,8 +120,7 @@ func getTargetFilepaths(ds []string, ext string) ([]string, error) {
}

if filepath.Ext(name) == "."+ext {
n := strings.Replace(name, "."+ext, "", -1)
names = append(names, n)
names = append(names, name)
}

return nil
Expand Down
5 changes: 3 additions & 2 deletions kadai2/tanaka0325/imgconv/imgconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ConvertParam struct {

// Do is func to convert image format.
func Do(param ConvertParam) (err error) {
r, err := param.File.Open(param.Path + "." + param.FromExt)
r, err := param.File.Open(param.Path)
if err != nil {
return
}
Expand All @@ -24,7 +24,8 @@ func Do(param ConvertParam) (err error) {
return
}

w, err := param.File.Create(param.Path + "." + param.ToExt)
e := len(param.Path) - len(param.FromExt)
w, err := param.File.Create(param.Path[:e] + param.ToExt)
if err != nil {
return err
}
Expand Down

0 comments on commit 2eea02e

Please sign in to comment.