diff --git a/Makefile b/Makefile index 49c4e1d..18507ad 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ test: format: @echo === FORMATTING === - go fmt *.go + go fmt ./... $(BIN_DIR): mkdir -p $@ diff --git a/command_test.go b/command_test.go index c7f968a..ef3e801 100644 --- a/command_test.go +++ b/command_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/assert" ) - func TestGetFn(t *testing.T) { c := newCommand() diff --git a/hook/hook_test.go b/hook/hook_test.go index 87dc63a..f2c6dff 100644 --- a/hook/hook_test.go +++ b/hook/hook_test.go @@ -7,7 +7,7 @@ import ( ) func TestAddHook(t *testing.T) { - + h := NewEventHook() h.AddHook("a", nil) @@ -31,7 +31,7 @@ func TestRunHooks(t *testing.T) { h := NewEventHook() x := 0 - for i := 0; i < 100; i ++ { + for i := 0; i < 100; i++ { h.AddHook("sample", func() { x++ }) diff --git a/invidious/invidious.go b/invidious/invidious.go index 7a16f09..24f0786 100644 --- a/invidious/invidious.go +++ b/invidious/invidious.go @@ -69,7 +69,7 @@ func (_ *Invidious) GetSuggestions(prefix string) ([]string, error) { return suggestions, nil } -// GetTrendingMusic fetch music trending based on region. +// GetTrendingMusic fetch music trending based on region. // Region (ISO 3166 country code) can be provided in the argument. func (i *Invidious) GetTrendingMusic(region string) ([]YoutubeVideo, error) { @@ -83,7 +83,7 @@ func (i *Invidious) GetTrendingMusic(region string) ([]YoutubeVideo, error) { return nil, err } - return yt, nil + return yt, nil } // getRequest is a helper function that simplifies GET request and parsing the diff --git a/player/player.go b/player/player.go index 1d8e69a..ee666a8 100644 --- a/player/player.go +++ b/player/player.go @@ -218,7 +218,6 @@ func (p *Player) Skip() { p.execSongFinish(p.currentSong) } - // GetPosition returns the current position of audio file. func (p *Player) GetPosition() time.Duration { diff --git a/playlist_test.go b/playlist_test.go index a5156fb..19560b3 100644 --- a/playlist_test.go +++ b/playlist_test.go @@ -6,8 +6,8 @@ import ( "path/filepath" "testing" - "github.com/rivo/tview" "github.com/issadarkthing/gomu/player" + "github.com/rivo/tview" ) // Prepares for test diff --git a/queue.go b/queue.go index 62819ac..07db4dd 100644 --- a/queue.go +++ b/queue.go @@ -219,7 +219,7 @@ func (q *Queue) saveQueue(isQuit bool) error { currentSongInQueue = true } } - if !currentSongInQueue { + if !currentSongInQueue && len(q.items) != 0 { hashed := sha1Hex(getName(currentSongPath)) content.WriteString(hashed + "\n") } diff --git a/queue_test.go b/queue_test.go index ce54deb..f814e82 100644 --- a/queue_test.go +++ b/queue_test.go @@ -94,7 +94,6 @@ func TestPushFront(t *testing.T) { gomu.playlist.addAllToQueue(rapPlaylist) - selSong, err := gomu.queue.deleteItem(2) if err != nil { t.Error(err) diff --git a/start.go b/start.go index 44257b1..82e3463 100644 --- a/start.go +++ b/start.go @@ -470,15 +470,10 @@ func start(application *tview.Application, args Args) { init := false gomu.app.SetAfterDrawFunc(func(_ tcell.Screen) { - if !init { + if !init && !gomu.player.IsRunning() { gomu.playingBar.setDefault() init = true } - if gomu.player.IsRunning() { - gomu.playingBar.setSongTitle(gomu.player.GetCurrentSong().Name()) - } else { - gomu.playingBar.setDefault() - } }) go populateAudioLength(gomu.playlist.GetRoot()) diff --git a/start_test.go b/start_test.go index 6c302f7..24fa01b 100644 --- a/start_test.go +++ b/start_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/assert" ) - func TestSetupHooks(t *testing.T) { gomu := newGomu() diff --git a/utils_test.go b/utils_test.go index 661df12..79badbf 100644 --- a/utils_test.go +++ b/utils_test.go @@ -119,7 +119,7 @@ func TestEmbedLyric(t *testing.T) { } f.Close() - defer func(){ + defer func() { err := os.Remove(testFile) if err != nil { t.Error(err)