Replaced error if/else checks with switch/case, to keep things consistent
This commit is contained in:
parent
283b4fccec
commit
4b596743f7
15
cmd/files.go
15
cmd/files.go
|
@ -112,17 +112,19 @@ func humanReadableSize(bytes int) string {
|
|||
|
||||
func getImageDimensions(path string) (*Dimensions, error) {
|
||||
file, err := os.Open(path)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
switch {
|
||||
case errors.Is(err, os.ErrNotExist):
|
||||
return &Dimensions{}, nil
|
||||
} else if err != nil {
|
||||
case err != nil:
|
||||
return &Dimensions{}, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
myImage, _, err := image.DecodeConfig(file)
|
||||
if errors.Is(err, image.ErrFormat) {
|
||||
switch {
|
||||
case errors.Is(err, image.ErrFormat):
|
||||
return &Dimensions{Width: 0, Height: 0}, nil
|
||||
} else if err != nil {
|
||||
case err != nil:
|
||||
return &Dimensions{}, err
|
||||
}
|
||||
|
||||
|
@ -357,9 +359,10 @@ func pathIsValid(filePath string, paths []string) bool {
|
|||
|
||||
func isImage(path string) (bool, error) {
|
||||
file, err := os.Open(path)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
switch {
|
||||
case errors.Is(err, os.ErrNotExist):
|
||||
return false, nil
|
||||
} else if err != nil {
|
||||
case err != nil:
|
||||
return false, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var Version = "0.25.0"
|
||||
var Version = "0.25.1"
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
|
|
Loading…
Reference in New Issue