diff --git a/backend/cmdlineoptions.go b/backend/cmdlineoptions.go index 22e792c..1f968a5 100644 --- a/backend/cmdlineoptions.go +++ b/backend/cmdlineoptions.go @@ -58,9 +58,7 @@ func init() { return err }) flag.Func("volume-adjust-pct", "adjusts volume up or down by the given percentage (positive or negative)", func(s string) error { - if strings.HasSuffix(s, "%") { - s = s[:len(s)-1] - } + s = strings.TrimSuffix(s, "%") v, err := strconv.ParseFloat(s, 64) VolumePctCLIArg = v return err diff --git a/backend/mediaprovider/subsonic/artistiterator.go b/backend/mediaprovider/subsonic/artistiterator.go index 35e2587..d6b21be 100644 --- a/backend/mediaprovider/subsonic/artistiterator.go +++ b/backend/mediaprovider/subsonic/artistiterator.go @@ -22,11 +22,8 @@ func (s *subsonicMediaProvider) ArtistSortOrders() []string { } } -func filterArtistMatches(f mediaprovider.ArtistFilter, artist *subsonic.ArtistID3) bool { - if artist == nil { - return false - } - return true +func filterArtistMatches(_ mediaprovider.ArtistFilter, artist *subsonic.ArtistID3) bool { + return artist != nil } func (s *subsonicMediaProvider) IterateArtists(sortOrder string, filter mediaprovider.ArtistFilter) mediaprovider.ArtistIterator { @@ -176,9 +173,7 @@ func (s *subsonicMediaProvider) artistFetchFnFromStandardSort(sortFn func([]*sub } var artists []*subsonic.ArtistID3 for _, idx := range idxs.Index { - for _, ar := range idx.Artist { - artists = append(artists, ar) - } + artists = append(artists, idx.Artist...) } artists = sortFn(artists) return artists, nil diff --git a/backend/windows/smtc_unsupported.go b/backend/windows/smtc_unsupported.go index 132c50b..5a64846 100644 --- a/backend/windows/smtc_unsupported.go +++ b/backend/windows/smtc_unsupported.go @@ -24,18 +24,18 @@ const ( type SMTC struct{} -var smtcUnsupportedErr = errors.New("SMTC is not supported on this platformo") +var errSMTCUnsupported = errors.New("no support for SMTC on this platform") func InitSMTCForWindow(hwnd uintptr) (*SMTC, error) { - return nil, smtcUnsupportedErr + return nil, errSMTCUnsupported } func (s *SMTC) SetEnabled(enabled bool) error { - return smtcUnsupportedErr + return errSMTCUnsupported } func (s *SMTC) SetThumbnail(filepath string) error { - return smtcUnsupportedErr + return errSMTCUnsupported } func (s *SMTC) OnButtonPressed(func(SMTCButton)) {} @@ -45,13 +45,13 @@ func (s *SMTC) OnSeek(f func(millis int)) {} func (s *SMTC) Shutdown() {} func (s *SMTC) UpdatePlaybackState(state SMTCPlaybackState) error { - return smtcUnsupportedErr + return errSMTCUnsupported } func (s *SMTC) UpdateMetadata(title, artist string) error { - return smtcUnsupportedErr + return errSMTCUnsupported } func (s *SMTC) UpdatePosition(positionMillis, durationMillis int) error { - return smtcUnsupportedErr + return errSMTCUnsupported } diff --git a/ui/controller/controller.go b/ui/controller/controller.go index 61b70fd..83b56e5 100644 --- a/ui/controller/controller.go +++ b/ui/controller/controller.go @@ -2,6 +2,7 @@ package controller import ( "archive/zip" + "errors" "fmt" "image" "image/color" @@ -546,7 +547,7 @@ func (c *Controller) sendNotification(title, content string) { func (c *Controller) showError(content string) { // TODO: display an in-app toast message instead of a dialog. - dialog.ShowError(fmt.Errorf(content), c.MainWindow) + dialog.ShowError(errors.New(content), c.MainWindow) } func (c *Controller) ShowAlbumInfoDialog(albumID, albumName string, albumCover image.Image) { diff --git a/ui/widgets/gridviewitem.go b/ui/widgets/gridviewitem.go index 5f82b8d..291b72a 100644 --- a/ui/widgets/gridviewitem.go +++ b/ui/widgets/gridviewitem.go @@ -378,11 +378,10 @@ func setPlayBtnTranslucency(f float32) { // get theme Primary color as color.NRGBA var primary color.NRGBA - switch pr := theme.Color(theme.ColorNamePrimary); pr.(type) { + switch pr := theme.Color(theme.ColorNamePrimary).(type) { case color.NRGBA: - primary = pr.(color.NRGBA) + primary = pr case color.RGBA: - pr := pr.(color.RGBA) primary = color.NRGBA{R: pr.R, G: pr.G, B: pr.B, A: pr.A} }