Skip to content

🎧 Your Personal Streaming Service

go fmt

Deluan012958cd088b
diff --git a/api/get_indexes_test.go b/api/get_indexes_test.go
index 4de3c28ff..7df7790e5 100644
--- a/api/get_indexes_test.go
+++ b/api/get_indexes_test.go
@@ -6,9 +6,9 @@ import (
"github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/consts"
"github.com/deluan/gosonic/domain"
+ . "github.com/deluan/gosonic/tests"
"github.com/deluan/gosonic/tests/mocks"
"github.com/deluan/gosonic/utils"
- . "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
)
diff --git a/api/get_music_directory.go b/api/get_music_directory.go
index 038c4516c..43ed9a1b0 100644
--- a/api/get_music_directory.go
+++ b/api/get_music_directory.go
@@ -1,11 +1,11 @@
package api
import (
+ "github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/utils"
"github.com/karlkfi/inject"
- "github.com/astaxie/beego"
)
type GetMusicDirectoryController struct {
@@ -74,7 +74,7 @@ func (c *GetMusicDirectoryController) Get() {
c.SendResponse(response)
}
-func (c *GetMusicDirectoryController) retrieveArtist(id string) (a *domain.Artist, as[]domain.Album, found bool) {
+func (c *GetMusicDirectoryController) retrieveArtist(id string) (a *domain.Artist, as []domain.Album, found bool) {
found, err := c.artistRepo.Exists(id)
if err != nil {
beego.Error("Error searching for Artist:", err)
@@ -96,7 +96,7 @@ func (c *GetMusicDirectoryController) retrieveArtist(id string) (a *domain.Artis
return
}
-func (c *GetMusicDirectoryController) retrieveAlbum(id string) (al *domain.Album, mfs[]domain.MediaFile, found bool) {
+func (c *GetMusicDirectoryController) retrieveAlbum(id string) (al *domain.Album, mfs []domain.MediaFile, found bool) {
found, err := c.albumRepo.Exists(id)
if err != nil {
beego.Error("Error searching for Album:", err)
diff --git a/api/get_music_directory_test.go b/api/get_music_directory_test.go
index 8b6f189eb..89b024974 100644
--- a/api/get_music_directory_test.go
+++ b/api/get_music_directory_test.go
@@ -3,12 +3,12 @@ package api_test
import (
"testing"
+ "github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/domain"
+ . "github.com/deluan/gosonic/tests"
"github.com/deluan/gosonic/tests/mocks"
"github.com/deluan/gosonic/utils"
- . "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
- "github.com/deluan/gosonic/api/responses"
)
func TestGetMusicDirectory(t *testing.T) {
@@ -81,4 +81,4 @@ func TestGetMusicDirectory(t *testing.T) {
mockMediaFileRepo.SetError(false)
})
})
-}
\ No newline at end of file
+}
diff --git a/api/ping_test.go b/api/ping_test.go
index dbf96d991..a90cbd486 100644
--- a/api/ping_test.go
+++ b/api/ping_test.go
@@ -1,11 +1,11 @@
package api_test
import (
+ "encoding/json"
"github.com/deluan/gosonic/api/responses"
. "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"testing"
- "encoding/json"
)
func TestPing(t *testing.T) {
diff --git a/api/responses/responses.go b/api/responses/responses.go
index ae2522ddd..a0df4c91f 100644
--- a/api/responses/responses.go
+++ b/api/responses/responses.go
@@ -18,17 +18,17 @@ type JsonWrapper struct {
}
type Error struct {
- Code int `xml:"code,attr" json:"code"`
- Message string `xml:"message,attr" json: "message"`
+ Code int `xml:"code,attr" json:"code"`
+ Message string `xml:"message,attr" json: "message"`
}
type License struct {
- Valid bool `xml:"valid,attr" json:"valid"`
+ Valid bool `xml:"valid,attr" json:"valid"`
}
type MusicFolder struct {
- Id string `xml:"id,attr" json:"id"`
- Name string `xml:"name,attr" json:"name"`
+ Id string `xml:"id,attr" json:"id"`
+ Name string `xml:"name,attr" json:"name"`
}
type MusicFolders struct {
@@ -36,8 +36,8 @@ type MusicFolders struct {
}
type Artist struct {
- Id string `xml:"id,attr" json:"id"`
- Name string `xml:"name,attr" json:"name"`
+ Id string `xml:"id,attr" json:"id"`
+ Name string `xml:"name,attr" json:"name"`
}
type Index struct {
@@ -46,32 +46,32 @@ type Index struct {
}
type Indexes struct {
- Index []Index `xml:"index" json:"index,omitempty"`
- LastModified string `xml:"lastModified,attr" json:"lastModified"`
- IgnoredArticles string `xml:"ignoredArticles,attr" json:"ignoredArticles"`
+ Index []Index `xml:"index" json:"index,omitempty"`
+ LastModified string `xml:"lastModified,attr" json:"lastModified"`
+ IgnoredArticles string `xml:"ignoredArticles,attr" json:"ignoredArticles"`
}
type Child struct {
- Id string `xml:"id,attr" json:"id"`
- IsDir bool `xml:"isDir,attr" json:"isDir"`
- Title string `xml:"title,attr" json:"title"`
- Album string `xml:"album,attr,omitempty" json:"album,omitempty"`
- Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
- Track int `xml:"track,attr,omitempty" json:"track,omitempty"`
- Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
- Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
- CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
- Size string `xml:"size,attr,omitempty" json:"size,omitempty"`
- ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
- Suffix string `xml:"suffix,attr,omitempty" json:"suffix,omitempty"`
- TranscodedContentType string `xml:"transcodedContentType,attr,omitempty" json:"transcodedContentType,omitempty"`
- TranscodedSuffix string `xml:"transcodedSuffix,attr,omitempty" json:"transcodedSuffix,omitempty"`
- Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
- BitRate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
+ Id string `xml:"id,attr" json:"id"`
+ IsDir bool `xml:"isDir,attr" json:"isDir"`
+ Title string `xml:"title,attr" json:"title"`
+ Album string `xml:"album,attr,omitempty" json:"album,omitempty"`
+ Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
+ Track int `xml:"track,attr,omitempty" json:"track,omitempty"`
+ Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
+ Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
+ CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
+ Size string `xml:"size,attr,omitempty" json:"size,omitempty"`
+ ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
+ Suffix string `xml:"suffix,attr,omitempty" json:"suffix,omitempty"`
+ TranscodedContentType string `xml:"transcodedContentType,attr,omitempty" json:"transcodedContentType,omitempty"`
+ TranscodedSuffix string `xml:"transcodedSuffix,attr,omitempty" json:"transcodedSuffix,omitempty"`
+ Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
+ BitRate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
}
type Directory struct {
- Child []Child `xml:"child" json:"child,omitempty"`
- Id string `xml:"id,attr" json:"id"`
- Name string `xml:"name,attr" json:"name"`
-}
\ No newline at end of file
+ Child []Child `xml:"child" json:"child,omitempty"`
+ Id string `xml:"id,attr" json:"id"`
+ Name string `xml:"name,attr" json:"name"`
+}
diff --git a/api/responses/responses_test.go b/api/responses/responses_test.go
index 344f13132..a352630e4 100644
--- a/api/responses/responses_test.go
+++ b/api/responses/responses_test.go
@@ -1,10 +1,10 @@
package responses_test
import (
- "testing"
- . "github.com/smartystreets/goconvey/convey"
- . "github.com/deluan/gosonic/tests"
. "github.com/deluan/gosonic/api/responses"
+ . "github.com/deluan/gosonic/tests"
+ . "github.com/smartystreets/goconvey/convey"
+ "testing"
)
func TestSubsonicResponses(t *testing.T) {
@@ -60,7 +60,7 @@ func TestSubsonicResponses(t *testing.T) {
Convey("Indexes", func() {
artists := make([]Artist, 1)
artists[0] = Artist{Id: "111", Name: "aaa"}
- response.Indexes = &Indexes{LastModified:"1", IgnoredArticles:"A"}
+ response.Indexes = &Indexes{LastModified: "1", IgnoredArticles: "A"}
Convey("With data", func() {
index := make([]Index, 1)
@@ -95,7 +95,7 @@ func TestSubsonicResponses(t *testing.T) {
})
Convey("With just required data", func() {
child := make([]Child, 1)
- child[0] = Child{ Id:"1", Title: "title", IsDir: false }
+ child[0] = Child{Id: "1", Title: "title", IsDir: false}
response.Directory.Child = child
Convey("XML", func() {
So(response, ShouldMatchXML, `<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.0.0"><directory id="1" name="N"><child id="1" isDir="false" title="title"></child></directory></subsonic-response>`)
@@ -107,7 +107,7 @@ func TestSubsonicResponses(t *testing.T) {
Convey("With all data", func() {
child := make([]Child, 1)
child[0] = Child{
- Id:"1", IsDir: true, Title: "title", Album: "album", Artist: "artist", Track: 1,
+ Id: "1", IsDir: true, Title: "title", Album: "album", Artist: "artist", Track: 1,
Year: 1985, Genre: "Rock", CoverArt: "1", Size: "8421341", ContentType: "audio/flac",
Suffix: "flac", TranscodedContentType: "audio/mpeg", TranscodedSuffix: "mp3",
Duration: 146, BitRate: 320,
@@ -127,4 +127,4 @@ func TestSubsonicResponses(t *testing.T) {
})
})
-}
\ No newline at end of file
+}
diff --git a/persistence/base_repository.go b/persistence/base_repository.go
index 9adee0e48..7b1ebe4e7 100644
--- a/persistence/base_repository.go
+++ b/persistence/base_repository.go
@@ -40,7 +40,7 @@ func (r *baseRepository) CountAll() (int, error) {
}
func (r *baseRepository) Exists(id string) (bool, error) {
- res, err := db().SIsMember([]byte(r.table + "s:all"), []byte(id))
+ res, err := db().SIsMember([]byte(r.table+"s:all"), []byte(id))
return res != 0, err
}
@@ -132,7 +132,7 @@ func (r *baseRepository) loadAll(entities interface{}, sortBy string, alpha bool
return r.loadFromSet(setName, entities, sortBy, alpha)
}
-func (r* baseRepository) loadChildren(parentTable string, parentId string, entities interface{}, sortBy string, alpha bool) error {
+func (r *baseRepository) loadChildren(parentTable string, parentId string, entities interface{}, sortBy string, alpha bool) error {
setName := fmt.Sprintf("%s:%s:%ss", parentTable, parentId, r.table)
return r.loadFromSet(setName, entities, sortBy, alpha)
}
@@ -161,4 +161,4 @@ func (r *baseRepository) loadFromSet(setName string, entities interface{}, sortB
return nil
-}
\ No newline at end of file
+}
diff --git a/persistence/mediafile_repository.go b/persistence/mediafile_repository.go
index f2d700b5c..170bb809a 100644
--- a/persistence/mediafile_repository.go
+++ b/persistence/mediafile_repository.go
@@ -35,5 +35,5 @@ func (a byTrackNumber) Swap(i, j int) {
a[i], a[j] = a[j], a[i]
}
func (a byTrackNumber) Less(i, j int) bool {
- return (a[i].DiscNumber * 1000 + a[i].TrackNumber) < (a[j].DiscNumber * 1000 + a[j].TrackNumber)
+ return (a[i].DiscNumber*1000 + a[i].TrackNumber) < (a[j].DiscNumber*1000 + a[j].TrackNumber)
}
diff --git a/scanner/itunes_scanner.go b/scanner/itunes_scanner.go
index f4a8bd68a..94ce105ac 100644
--- a/scanner/itunes_scanner.go
+++ b/scanner/itunes_scanner.go
@@ -4,9 +4,9 @@ import (
"github.com/dhowden/itl"
"net/url"
"os"
- "strings"
"path/filepath"
"strconv"
+ "strings"
)
type ItunesScanner struct{}
diff --git a/scanner/scanner.go b/scanner/scanner.go
index 82972cb61..14ee2ee52 100644
--- a/scanner/scanner.go
+++ b/scanner/scanner.go
@@ -89,7 +89,7 @@ func parseTrack(t *Track) (*domain.MediaFile, *domain.Album, *domain.Artist) {
Year: t.Year,
Compilation: t.Compilation,
Genre: t.Genre,
- Artist: t.Artist,
+ Artist: t.Artist,
AlbumArtist: t.AlbumArtist,
}
diff --git a/tests/matchers.go b/tests/matchers.go
index 015bd21d5..1793335b3 100644
--- a/tests/matchers.go
+++ b/tests/matchers.go
@@ -1,12 +1,12 @@
package tests
import (
- . "github.com/smartystreets/goconvey/convey"
+ "bytes"
"encoding/json"
"encoding/xml"
"fmt"
"github.com/deluan/gosonic/api/responses"
- "bytes"
+ . "github.com/smartystreets/goconvey/convey"
)
func ShouldMatchXML(actual interface{}, expected ...interface{}) string {
@@ -48,4 +48,4 @@ func UnindentJSON(j []byte) string {
json.Unmarshal(j, &m)
s, _ := json.Marshal(m)
return string(s)
-}
\ No newline at end of file
+}
diff --git a/tests/mocks/mock_album_repo.go b/tests/mocks/mock_album_repo.go
index 5b1db7dc9..5645a8cee 100644
--- a/tests/mocks/mock_album_repo.go
+++ b/tests/mocks/mock_album_repo.go
@@ -2,9 +2,9 @@ package mocks
import (
"encoding/json"
+ "errors"
"fmt"
"github.com/deluan/gosonic/domain"
-"errors"
)
func CreateMockAlbumRepo() *MockAlbum {
@@ -37,7 +37,7 @@ func (m *MockAlbum) Exists(id string) (bool, error) {
if m.err {
return false, errors.New("Error!")
}
- _, found := m.data[id];
+ _, found := m.data[id]
return found, nil
}
@@ -62,4 +62,4 @@ func (m *MockAlbum) FindByArtist(artistId string) ([]domain.Album, error) {
}
return res, nil
-}
\ No newline at end of file
+}
diff --git a/tests/mocks/mock_artist_repo.go b/tests/mocks/mock_artist_repo.go
index c19ed4cdd..29cf51786 100644
--- a/tests/mocks/mock_artist_repo.go
+++ b/tests/mocks/mock_artist_repo.go
@@ -2,9 +2,9 @@ package mocks
import (
"encoding/json"
+ "errors"
"fmt"
"github.com/deluan/gosonic/domain"
-"errors"
)
func CreateMockArtistRepo() *MockArtist {
@@ -37,7 +37,7 @@ func (m *MockArtist) Exists(id string) (bool, error) {
if m.err {
return false, errors.New("Error!")
}
- _, found := m.data[id];
+ _, found := m.data[id]
return found, nil
}
@@ -46,4 +46,4 @@ func (m *MockArtist) Get(id string) (*domain.Artist, error) {
return nil, errors.New("Error!")
}
return m.data[id], nil
-}
\ No newline at end of file
+}
diff --git a/tests/mocks/mock_mediafile_repo.go b/tests/mocks/mock_mediafile_repo.go
index 8c35c36d8..15c5906d0 100644
--- a/tests/mocks/mock_mediafile_repo.go
+++ b/tests/mocks/mock_mediafile_repo.go
@@ -2,9 +2,9 @@ package mocks
import (
"encoding/json"
+ "errors"
"fmt"
"github.com/deluan/gosonic/domain"
-"errors"
)
func CreateMockMediaFileRepo() *MockMediaFile {
@@ -37,7 +37,7 @@ func (m *MockMediaFile) Exists(id string) (bool, error) {
if m.err {
return false, errors.New("Error!")
}
- _, found := m.data[id];
+ _, found := m.data[id]
return found, nil
}
@@ -62,4 +62,4 @@ func (m *MockMediaFile) FindByAlbum(artistId string) ([]domain.MediaFile, error)
}
return res, nil
-}
\ No newline at end of file
+}