Skip to content

🎧 Your Personal Streaming Service

go fmt

Deluan4843ccb46c86
diff --git a/api/api_test.go b/api/api_test.go
index 04acdfa97..0bbc1b729 100644
--- a/api/api_test.go
+++ b/api/api_test.go
@@ -3,17 +3,17 @@ package api_test
import (
"fmt"
"github.com/astaxie/beego"
+ _ "github.com/deluan/gosonic/conf"
"net/http"
"net/http/httptest"
- _ "github.com/deluan/gosonic/conf"
"strings"
)
const (
- testUser = "deluan"
+ testUser = "deluan"
testPassword = "wordpass"
- testClient = "test"
- testVersion = "1.0.0"
+ testClient = "test"
+ testVersion = "1.0.0"
)
func AddParams(endpoint string, params ...string) string {
diff --git a/api/base_api_controller.go b/api/base_api_controller.go
index 80cf9a369..fda548e44 100644
--- a/api/base_api_controller.go
+++ b/api/base_api_controller.go
@@ -1,10 +1,10 @@
package api
import (
+ "encoding/xml"
+ "fmt"
"github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses"
- "fmt"
-"encoding/xml"
)
type BaseAPIController struct{ beego.Controller }
@@ -16,7 +16,7 @@ func (c *BaseAPIController) NewEmpty() responses.Subsonic {
func (c *BaseAPIController) SendError(errorCode int, message ...interface{}) {
response := responses.Subsonic{Version: beego.AppConfig.String("apiVersion"), Status: "fail"}
var msg string
- if (len(message) == 0) {
+ if len(message) == 0 {
msg = responses.ErrorMsg(errorCode)
} else {
msg = fmt.Sprintf(message[0].(string), message[1:len(message)]...)
@@ -24,13 +24,15 @@ func (c *BaseAPIController) SendError(errorCode int, message ...interface{}) {
response.Error = &responses.Error{Code: errorCode, Message: msg}
xmlBody, _ := xml.Marshal(&response)
- c.CustomAbort(200, xml.Header + string(xmlBody))
+ c.CustomAbort(200, xml.Header+string(xmlBody))
}
func (c *BaseAPIController) prepResponse(response responses.Subsonic) interface{} {
f := c.GetString("f")
if f == "json" {
- type jsonWrapper struct{ Subsonic responses.Subsonic `json:"subsonic-response"` }
+ type jsonWrapper struct {
+ Subsonic responses.Subsonic `json:"subsonic-response"`
+ }
return jsonWrapper{Subsonic: response}
}
return response
@@ -39,7 +41,9 @@ func (c *BaseAPIController) prepResponse(response responses.Subsonic) interface{
func (c *BaseAPIController) SendResponse(response responses.Subsonic) {
f := c.GetString("f")
if f == "json" {
- type jsonWrapper struct{ Subsonic responses.Subsonic `json:"subsonic-response"` }
+ type jsonWrapper struct {
+ Subsonic responses.Subsonic `json:"subsonic-response"`
+ }
w := &jsonWrapper{Subsonic: response}
c.Data["json"] = &w
c.ServeJSON()
@@ -48,4 +52,3 @@ func (c *BaseAPIController) SendResponse(response responses.Subsonic) {
c.ServeXML()
}
}
-
diff --git a/api/get_indexes.go b/api/get_indexes.go
index 53d5aaae8..69fa1ca31 100644
--- a/api/get_indexes.go
+++ b/api/get_indexes.go
@@ -2,12 +2,12 @@ package api
import (
"github.com/astaxie/beego"
- "github.com/deluan/gosonic/utils"
- "github.com/karlkfi/inject"
"github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/consts"
- "strconv"
"github.com/deluan/gosonic/domain"
+ "github.com/deluan/gosonic/utils"
+ "github.com/karlkfi/inject"
+ "strconv"
)
type GetIndexesController struct {
@@ -42,7 +42,7 @@ func (c *GetIndexesController) Get() {
i, _ := strconv.Atoi(ifModifiedSince)
l, _ := strconv.Atoi(res.LastModified)
- if (l > i) {
+ if l > i {
indexes, err := c.repo.GetAll()
if err != nil {
beego.Error("Error retrieving Indexes:", err)
diff --git a/api/get_indexes_test.go b/api/get_indexes_test.go
index ab3a675e3..e917f2ac6 100644
--- a/api/get_indexes_test.go
+++ b/api/get_indexes_test.go
@@ -3,14 +3,14 @@ package api_test
import (
"testing"
- "github.com/deluan/gosonic/utils"
- . "github.com/smartystreets/goconvey/convey"
- "github.com/deluan/gosonic/tests"
"encoding/xml"
"github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/consts"
- "github.com/deluan/gosonic/tests/mocks"
"github.com/deluan/gosonic/domain"
+ "github.com/deluan/gosonic/tests"
+ "github.com/deluan/gosonic/tests/mocks"
+ "github.com/deluan/gosonic/utils"
+ . "github.com/smartystreets/goconvey/convey"
)
const (
@@ -104,4 +104,4 @@ func TestGetIndexes(t *testing.T) {
propRepo.SetError(false)
})
})
-}
\ No newline at end of file
+}
diff --git a/api/get_license_test.go b/api/get_license_test.go
index 22bd9ecf6..f4ac4da30 100644
--- a/api/get_license_test.go
+++ b/api/get_license_test.go
@@ -2,9 +2,9 @@ package api_test
import (
"encoding/xml"
+ "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"testing"
- "github.com/deluan/gosonic/tests"
)
func TestGetLicense(t *testing.T) {
diff --git a/api/get_music_folders.go b/api/get_music_folders.go
index 8c023708c..3aed8b50d 100644
--- a/api/get_music_folders.go
+++ b/api/get_music_folders.go
@@ -3,8 +3,8 @@ package api
import (
"github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/domain"
- "github.com/karlkfi/inject"
"github.com/deluan/gosonic/utils"
+ "github.com/karlkfi/inject"
)
type GetMusicFoldersController struct {
diff --git a/api/get_music_folders_test.go b/api/get_music_folders_test.go
index cfd727b64..dc85bd011 100644
--- a/api/get_music_folders_test.go
+++ b/api/get_music_folders_test.go
@@ -4,8 +4,8 @@ import (
"testing"
"encoding/xml"
- . "github.com/smartystreets/goconvey/convey"
"github.com/deluan/gosonic/tests"
+ . "github.com/smartystreets/goconvey/convey"
)
func TestGetMusicFolders(t *testing.T) {
diff --git a/api/ping_test.go b/api/ping_test.go
index 4f78345de..c8d83d12c 100644
--- a/api/ping_test.go
+++ b/api/ping_test.go
@@ -3,9 +3,9 @@ package api_test
import (
"encoding/xml"
"github.com/deluan/gosonic/api/responses"
+ "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"testing"
- "github.com/deluan/gosonic/tests"
)
func TestPing(t *testing.T) {
diff --git a/api/responses/responses.go b/api/responses/responses.go
index 0a2b3962f..4faf26615 100644
--- a/api/responses/responses.go
+++ b/api/responses/responses.go
@@ -3,53 +3,52 @@ package responses
import "encoding/xml"
type Subsonic struct {
- XMLName xml.Name `xml:"http://subsonic.org/restapi subsonic-response" json:"-"`
- Status string `xml:"status,attr" json:"status"`
- Version string `xml:"version,attr" json:"version"`
- Error *Error `xml:",omitempty" json:"error,omitempty"`
- License *License `xml:",omitempty" json:"license,omitempty"`
- MusicFolders *MusicFolders `xml:",omitempty" json:"musicFolders,omitempty"`
- ArtistIndex *Indexes `xml:",omitempty" json:"indexes,omitempty"`
+ XMLName xml.Name `xml:"http://subsonic.org/restapi subsonic-response" json:"-"`
+ Status string `xml:"status,attr" json:"status"`
+ Version string `xml:"version,attr" json:"version"`
+ Error *Error `xml:",omitempty" json:"error,omitempty"`
+ License *License `xml:",omitempty" json:"license,omitempty"`
+ MusicFolders *MusicFolders `xml:",omitempty" json:"musicFolders,omitempty"`
+ ArtistIndex *Indexes `xml:",omitempty" json:"indexes,omitempty"`
}
type Error struct {
- XMLName xml.Name `xml:"error" json:"-"`
+ XMLName xml.Name `xml:"error" json:"-"`
Code int `xml:"code,attr"`
Message string `xml:"message,attr"`
}
type License struct {
- XMLName xml.Name `xml:"license" json:"-" json:"-"`
- Valid bool `xml:"valid,attr" json:"valid"`
+ XMLName xml.Name `xml:"license" json:"-"`
+ Valid bool `xml:"valid,attr" json:"valid"`
}
type MusicFolder struct {
- XMLName xml.Name `xml:"musicFolder" json:"-"`
- Id string `xml:"id,attr" json:"id"`
- Name string `xml:"name,attr" json:"name"`
+ XMLName xml.Name `xml:"musicFolder" json:"-"`
+ Id string `xml:"id,attr" json:"id"`
+ Name string `xml:"name,attr" json:"name"`
}
type MusicFolders struct {
- XMLName xml.Name `xml:"musicFolders" json:"-"`
- Folders []MusicFolder `xml:"musicFolders" json:"musicFolder"`
+ XMLName xml.Name `xml:"musicFolders" json:"-"`
+ Folders []MusicFolder `xml:"musicFolders" json:"musicFolder"`
}
type Artist struct {
- XMLName xml.Name `xml:"artist" json:"-"`
- Id string `xml:"id,attr" json:"id"`
- Name string `xml:"name,attr" json:"name"`
+ XMLName xml.Name `xml:"artist" json:"-"`
+ Id string `xml:"id,attr" json:"id"`
+ Name string `xml:"name,attr" json:"name"`
}
type Index struct {
- XMLName xml.Name `xml:"index" json:"-"`
- Name string `xml:"name,attr" json:"name"`
- Artists []Artist `xml:"index" json:"artist"`
+ XMLName xml.Name `xml:"index" json:"-"`
+ Name string `xml:"name,attr" json:"name"`
+ Artists []Artist `xml:"index" json:"artist"`
}
type Indexes struct {
- XMLName xml.Name `xml:"indexes" json:"-"`
- Index []Index `xml:"indexes" json:"index"`
- LastModified string `xml:"lastModified,attr" json:"lastModified"`
- IgnoredArticles string `xml:"ignoredArticles,attr" json:"ignoredArticles"`
+ XMLName xml.Name `xml:"indexes" json:"-"`
+ Index []Index `xml:"indexes" json:"index"`
+ LastModified string `xml:"lastModified,attr" json:"lastModified"`
+ IgnoredArticles string `xml:"ignoredArticles,attr" json:"ignoredArticles"`
}
-
diff --git a/api/validation_test.go b/api/validation_test.go
index 983857a8f..92e304e6a 100644
--- a/api/validation_test.go
+++ b/api/validation_test.go
@@ -3,9 +3,9 @@ package api_test
import (
"encoding/xml"
"github.com/deluan/gosonic/api/responses"
+ "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"testing"
- "github.com/deluan/gosonic/tests"
)
func TestCheckParams(t *testing.T) {
diff --git a/conf/inject_definitions.go b/conf/inject_definitions.go
index 1caa28a4a..3d30e1a00 100644
--- a/conf/inject_definitions.go
+++ b/conf/inject_definitions.go
@@ -1,12 +1,12 @@
package conf
import (
- "github.com/deluan/gosonic/utils"
- "github.com/deluan/gosonic/persistence"
"github.com/deluan/gosonic/domain"
+ "github.com/deluan/gosonic/persistence"
+ "github.com/deluan/gosonic/utils"
)
-func init () {
+func init() {
utils.DefineSingleton(new(domain.ArtistIndexRepository), persistence.NewArtistIndexRepository)
utils.DefineSingleton(new(domain.PropertyRepository), persistence.NewPropertyRepository)
utils.DefineSingleton(new(domain.MediaFolderRepository), persistence.NewMediaFolderRepository)
diff --git a/conf/router.go b/conf/router.go
index 18ed9d941..7f940b2e5 100644
--- a/conf/router.go
+++ b/conf/router.go
@@ -40,4 +40,4 @@ func mapFilters() {
}
beego.InsertFilter("/rest/*", beego.BeforeRouter, ValidateRequest)
-}
\ No newline at end of file
+}
diff --git a/controllers/main_test.go b/controllers/main_test.go
index af7f77e45..bcac7f093 100644
--- a/controllers/main_test.go
+++ b/controllers/main_test.go
@@ -1,14 +1,14 @@
package controllers_test
import (
+ "fmt"
+ "github.com/astaxie/beego"
+ _ "github.com/deluan/gosonic/conf"
"github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
- "testing"
"net/http"
"net/http/httptest"
- "github.com/astaxie/beego"
- "fmt"
- _ "github.com/deluan/gosonic/conf"
+ "testing"
)
func TestErrorHandler(t *testing.T) {
@@ -25,4 +25,4 @@ func TestErrorHandler(t *testing.T) {
So(w.Code, ShouldEqual, 404)
})
})
-}
\ No newline at end of file
+}
diff --git a/controllers/sync.go b/controllers/sync.go
index e401b0d8a..93499d7dd 100644
--- a/controllers/sync.go
+++ b/controllers/sync.go
@@ -11,5 +11,3 @@ func (c *SyncController) Get() {
scanner.StartImport()
c.Ctx.WriteString("Import started. Check logs")
}
-
-
diff --git a/domain/album.go b/domain/album.go
index ad06eb0a3..e7d9c9e91 100644
--- a/domain/album.go
+++ b/domain/album.go
@@ -14,4 +14,4 @@ type AlbumRepository interface {
BaseRepository
Put(m *Album) error
Get(id string) (*Album, error)
-}
\ No newline at end of file
+}
diff --git a/domain/artist.go b/domain/artist.go
index 34593188a..66bd2f407 100644
--- a/domain/artist.go
+++ b/domain/artist.go
@@ -1,8 +1,8 @@
package domain
type Artist struct {
- Id string
- Name string
+ Id string
+ Name string
}
type ArtistRepository interface {
@@ -11,4 +11,3 @@ type ArtistRepository interface {
Get(id string) (*Artist, error)
GetByName(name string) (*Artist, error)
}
-
diff --git a/domain/base.go b/domain/base.go
index a695432aa..ee37a8074 100644
--- a/domain/base.go
+++ b/domain/base.go
@@ -3,6 +3,4 @@ package domain
type BaseRepository interface {
NewId(fields ...string) string
CountAll() (int, error)
-
}
-
diff --git a/domain/index.go b/domain/index.go
index 2eee75fec..ae7220b45 100644
--- a/domain/index.go
+++ b/domain/index.go
@@ -2,15 +2,14 @@ package domain
type ArtistInfo struct {
ArtistId string
- Artist string
+ Artist string
}
type ArtistIndex struct {
- Id string
+ Id string
Artists []ArtistInfo
}
-
type ArtistIndexRepository interface {
BaseRepository
Put(m *ArtistIndex) error
diff --git a/domain/media_file.go b/domain/media_file.go
index 46b8edb50..7de4e7076 100644
--- a/domain/media_file.go
+++ b/domain/media_file.go
@@ -11,7 +11,7 @@ type MediaFile struct {
Album string
Artist string
AlbumArtist string
- AlbumId string `parent:"album"`
+ AlbumId string `parent:"album"`
Compilation bool
CreatedAt time.Time
UpdatedAt time.Time
@@ -20,4 +20,4 @@ type MediaFile struct {
type MediaFileRepository interface {
BaseRepository
Put(m *MediaFile) error
-}
\ No newline at end of file
+}
diff --git a/domain/media_folder.go b/domain/media_folder.go
index 205bf4e02..81ea7ab54 100644
--- a/domain/media_folder.go
+++ b/domain/media_folder.go
@@ -1,7 +1,7 @@
package domain
type MediaFolder struct {
- Id string
+ Id string
Name string
Path string
}
@@ -9,4 +9,3 @@ type MediaFolder struct {
type MediaFolderRepository interface {
GetAll() ([]MediaFolder, error)
}
-
diff --git a/domain/property.go b/domain/property.go
index e697ba6a7..d5e75eb7f 100644
--- a/domain/property.go
+++ b/domain/property.go
@@ -10,4 +10,3 @@ type PropertyRepository interface {
Get(id string) (string, error)
DefaultGet(id string, defaultValue string) (string, error)
}
-
diff --git a/main.go b/main.go
index b052f3982..acdf6e856 100644
--- a/main.go
+++ b/main.go
@@ -1,8 +1,8 @@
package main
import (
- _ "github.com/deluan/gosonic/conf"
"github.com/astaxie/beego"
+ _ "github.com/deluan/gosonic/conf"
)
func main() {
diff --git a/persistence/album_repository.go b/persistence/album_repository.go
index 1b0fc7d54..d80a195a7 100644
--- a/persistence/album_repository.go
+++ b/persistence/album_repository.go
@@ -25,4 +25,4 @@ func (r *albumRepository) Get(id string) (*domain.Album, error) {
var rec interface{}
rec, err := r.readEntity(id)
return rec.(*domain.Album), err
-}
\ No newline at end of file
+}
diff --git a/persistence/artist_repository.go b/persistence/artist_repository.go
index 1c4bc17fd..8bf79277d 100644
--- a/persistence/artist_repository.go
+++ b/persistence/artist_repository.go
@@ -31,4 +31,3 @@ func (r *artistRepository) GetByName(name string) (*domain.Artist, error) {
id := r.NewId(name)
return r.Get(id)
}
-
diff --git a/persistence/base_repository.go b/persistence/base_repository.go
index 2866c6587..20c25c478 100644
--- a/persistence/base_repository.go
+++ b/persistence/base_repository.go
@@ -1,12 +1,12 @@
package persistence
import (
- "fmt"
"crypto/md5"
- "strings"
- "github.com/deluan/gosonic/utils"
"encoding/json"
+ "fmt"
+ "github.com/deluan/gosonic/utils"
"reflect"
+ "strings"
)
type baseRepository struct {
@@ -90,7 +90,7 @@ func (r *baseRepository) getFieldKeys(id string) [][]byte {
return fieldKeys
}
-func (r*baseRepository) newInstance() interface{} {
+func (r *baseRepository) newInstance() interface{} {
return reflect.New(r.entityType).Interface()
}
@@ -123,7 +123,7 @@ func (r *baseRepository) toEntity(response [][]byte, entity interface{}) error {
// TODO Optimize it! Probably very slow (and confusing!)
func (r *baseRepository) loadAll(entities interface{}, sortBy string) error {
total, err := r.CountAll()
- if (err != nil) {
+ if err != nil {
return err
}
@@ -134,7 +134,7 @@ func (r *baseRepository) loadAll(entities interface{}, sortBy string) error {
}
setName := r.table + "s:all"
response, err := db().XSSort([]byte(setName), 0, 0, true, false, sortKey, r.getFieldKeys("*"))
- if (err != nil) {
+ if err != nil {
return err
}
numFields := len(r.fieldNames)
@@ -142,7 +142,7 @@ func (r *baseRepository) loadAll(entities interface{}, sortBy string) error {
start := i * numFields
entity := reflect.New(r.entityType).Interface()
- if err := r.toEntity(response[start:start + numFields], entity); err != nil {
+ if err := r.toEntity(response[start:start+numFields], entity); err != nil {
return err
}
reflected.Set(reflect.Append(reflected, reflect.ValueOf(entity).Elem()))
diff --git a/persistence/base_repository_test.go b/persistence/base_repository_test.go
index 2fbfdbb53..e0a8ed721 100644
--- a/persistence/base_repository_test.go
+++ b/persistence/base_repository_test.go
@@ -1,11 +1,11 @@
package persistence
import (
- "testing"
- . "github.com/smartystreets/goconvey/convey"
- "github.com/deluan/gosonic/tests"
"fmt"
+ "github.com/deluan/gosonic/tests"
+ . "github.com/smartystreets/goconvey/convey"
"strconv"
+ "testing"
)
type TestEntity struct {
diff --git a/persistence/index_repository.go b/persistence/index_repository.go
index 5c2768ce1..2c25dc803 100644
--- a/persistence/index_repository.go
+++ b/persistence/index_repository.go
@@ -1,10 +1,10 @@
package persistence
import (
- "github.com/deluan/gosonic/domain"
"errors"
- "sort"
+ "github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/utils"
+ "sort"
)
type artistIndex struct {
diff --git a/persistence/index_repository_test.go b/persistence/index_repository_test.go
index a25a59afd..519553919 100644
--- a/persistence/index_repository_test.go
+++ b/persistence/index_repository_test.go
@@ -1,11 +1,11 @@
package persistence
import (
- "testing"
- . "github.com/smartystreets/goconvey/convey"
- "github.com/deluan/gosonic/tests"
"github.com/deluan/gosonic/domain"
-"strconv"
+ "github.com/deluan/gosonic/tests"
+ . "github.com/smartystreets/goconvey/convey"
+ "strconv"
+ "testing"
)
func TestIndexRepository(t *testing.T) {
@@ -19,7 +19,7 @@ func TestIndexRepository(t *testing.T) {
i := &domain.ArtistIndex{Id: "123"}
repo.Put(i)
- s,_ := repo.Get("123")
+ s, _ := repo.Get("123")
So(s, shouldBeEqual, i)
})
@@ -37,7 +37,7 @@ func TestIndexRepository(t *testing.T) {
}
Convey("When I call GetAll()", func() {
- indices, err := repo.GetAll()
+ indices, err := repo.GetAll()
Convey("Then It should not return any error", func() {
So(err, ShouldBeNil)
})
@@ -55,4 +55,4 @@ func TestIndexRepository(t *testing.T) {
dropDb()
})
})
-}
\ No newline at end of file
+}
diff --git a/persistence/ledis_utils.go b/persistence/ledis_utils.go
index 384ef67a9..7b1f0fe3e 100644
--- a/persistence/ledis_utils.go
+++ b/persistence/ledis_utils.go
@@ -1,16 +1,16 @@
package persistence
import (
- "sync"
"github.com/astaxie/beego"
- "github.com/siddontang/ledisdb/ledis"
"github.com/siddontang/ledisdb/config"
+ "github.com/siddontang/ledisdb/ledis"
+ "sync"
)
var (
_ledisInstance *ledis.Ledis
- _dbInstance *ledis.DB
- once sync.Once
+ _dbInstance *ledis.DB
+ once sync.Once
)
func db() *ledis.DB {
@@ -28,8 +28,7 @@ func db() *ledis.DB {
return _dbInstance
}
-
func dropDb() {
db()
_ledisInstance.FlushAll()
-}
\ No newline at end of file
+}
diff --git a/persistence/media_file_repository.go b/persistence/media_file_repository.go
index 6097fcf9e..c132f0912 100644
--- a/persistence/media_file_repository.go
+++ b/persistence/media_file_repository.go
@@ -16,4 +16,4 @@ func NewMediaFileRepository() domain.MediaFileRepository {
func (r *mediaFileRepository) Put(m *domain.MediaFile) error {
return r.saveOrUpdate(m.Id, m)
-}
\ No newline at end of file
+}
diff --git a/persistence/media_folders_repository.go b/persistence/media_folders_repository.go
index 52c94e787..b160e8f11 100644
--- a/persistence/media_folders_repository.go
+++ b/persistence/media_folders_repository.go
@@ -1,8 +1,8 @@
package persistence
import (
- "github.com/deluan/gosonic/domain"
"github.com/astaxie/beego"
+ "github.com/deluan/gosonic/domain"
)
type mediaFolderRepository struct {
@@ -13,10 +13,9 @@ func NewMediaFolderRepository() domain.MediaFolderRepository {
return &mediaFolderRepository{}
}
-
func (*mediaFolderRepository) GetAll() ([]domain.MediaFolder, error) {
mediaFolder := domain.MediaFolder{Id: "0", Name: "iTunes Library", Path: beego.AppConfig.String("musicFolder")}
result := make([]domain.MediaFolder, 1)
result[0] = mediaFolder
return result, nil
-}
\ No newline at end of file
+}
diff --git a/persistence/property_repository.go b/persistence/property_repository.go
index 4681a8ac1..56760d283 100644
--- a/persistence/property_repository.go
+++ b/persistence/property_repository.go
@@ -1,8 +1,8 @@
package persistence
import (
+ "errors"
"github.com/deluan/gosonic/domain"
-"errors"
)
type propertyRepository struct {
@@ -29,7 +29,7 @@ func (r *propertyRepository) Get(id string) (string, error) {
return rec.(*domain.Property).Value, err
}
-func (r*propertyRepository) DefaultGet(id string, defaultValue string) (string, error) {
+func (r *propertyRepository) DefaultGet(id string, defaultValue string) (string, error) {
v, err := r.Get(id)
if v == "" {
diff --git a/scanner/itunes_scanner.go b/scanner/itunes_scanner.go
index f69686db7..fafdb4d9e 100644
--- a/scanner/itunes_scanner.go
+++ b/scanner/itunes_scanner.go
@@ -7,7 +7,7 @@ import (
"strings"
)
-type ItunesScanner struct {}
+type ItunesScanner struct{}
func (s *ItunesScanner) LoadFolder(path string) []Track {
xml, _ := os.Open(path)
@@ -35,8 +35,8 @@ func (s *ItunesScanner) LoadFolder(path string) []Track {
}
func unescape(s string) string {
- s,_ = url.QueryUnescape(s)
+ s, _ = url.QueryUnescape(s)
return strings.Replace(s, "&", "&", -1)
}
-var _ Scanner = (*ItunesScanner)(nil)
\ No newline at end of file
+var _ Scanner = (*ItunesScanner)(nil)
diff --git a/scanner/scanner.go b/scanner/scanner.go
index 19b50ca19..622a91335 100644
--- a/scanner/scanner.go
+++ b/scanner/scanner.go
@@ -1,14 +1,14 @@
package scanner
import (
+ "fmt"
"github.com/astaxie/beego"
- "github.com/deluan/gosonic/persistence"
+ "github.com/deluan/gosonic/consts"
"github.com/deluan/gosonic/domain"
+ "github.com/deluan/gosonic/persistence"
+ "github.com/deluan/gosonic/utils"
"strings"
-"github.com/deluan/gosonic/utils"
- "github.com/deluan/gosonic/consts"
"time"
- "fmt"
)
type Scanner interface {
@@ -29,7 +29,7 @@ func doImport(mediaFolder string, scanner Scanner) {
beego.Info("Finished importing", len(files), "files")
}
-func importLibrary(files []Track) (err error){
+func importLibrary(files []Track) (err error) {
indexGroups := utils.ParseIndexGroups(beego.AppConfig.String("indexGroups"))
mfRepo := persistence.NewMediaFileRepository()
albumRepo := persistence.NewAlbumRepository()
@@ -65,20 +65,20 @@ func importLibrary(files []Track) (err error){
func parseTrack(t *Track) (*domain.MediaFile, *domain.Album, *domain.Artist) {
mf := &domain.MediaFile{
- Id: t.Id,
- Album: t.Album,
- Artist: t.Artist,
+ Id: t.Id,
+ Album: t.Album,
+ Artist: t.Artist,
AlbumArtist: t.AlbumArtist,
- Title: t.Title,
+ Title: t.Title,
Compilation: t.Compilation,
- Path: t.Path,
- CreatedAt: t.CreatedAt,
- UpdatedAt: t.UpdatedAt,
+ Path: t.Path,
+ CreatedAt: t.CreatedAt,
+ UpdatedAt: t.UpdatedAt,
}
album := &domain.Album{
- Name: t.Album,
- Year: t.Year,
+ Name: t.Album,
+ Year: t.Year,
Compilation: t.Compilation,
}
@@ -145,4 +145,4 @@ func saveIndex(artistIndex map[string]tempIndex) error {
}
return nil
-}
\ No newline at end of file
+}
diff --git a/scanner/scanner_test.go b/scanner/scanner_test.go
index 14905744a..d991e191f 100644
--- a/scanner/scanner_test.go
+++ b/scanner/scanner_test.go
@@ -1,17 +1,17 @@
package scanner
import (
- "testing"
- . "github.com/smartystreets/goconvey/convey"
- "github.com/deluan/gosonic/utils"
"github.com/deluan/gosonic/domain"
-"github.com/deluan/gosonic/tests"
+ "github.com/deluan/gosonic/tests"
+ "github.com/deluan/gosonic/utils"
+ . "github.com/smartystreets/goconvey/convey"
+ "testing"
)
func TestCollectIndex(t *testing.T) {
tests.Init(t, false)
- ig := utils.IndexGroups{"A":"A", "B":"B", "Tom":"Tom", "X":"X-Z"}
+ ig := utils.IndexGroups{"A": "A", "B": "B", "Tom": "Tom", "X": "X-Z"}
Convey("Simple Name", t, func() {
a := &domain.Artist{Name: "Björk"}
diff --git a/scanner/track.go b/scanner/track.go
index 97169e76a..9fd61161b 100644
--- a/scanner/track.go
+++ b/scanner/track.go
@@ -18,11 +18,11 @@ type Track struct {
}
func (m *Track) RealArtist() string {
- if (m.Compilation) {
+ if m.Compilation {
return "Various Artists"
}
- if (m.AlbumArtist != "") {
+ if m.AlbumArtist != "" {
return m.AlbumArtist
}
return m.Artist
-}
\ No newline at end of file
+}
diff --git a/tests/init_tests.go b/tests/init_tests.go
index f604b662b..0447fe387 100644
--- a/tests/init_tests.go
+++ b/tests/init_tests.go
@@ -22,4 +22,3 @@ func Init(t *testing.T, skipOnShort bool) {
beego.SetLevel(beego.LevelError)
}
}
-
diff --git a/tests/mocks/mock_index_repo_tests.go b/tests/mocks/mock_index_repo_tests.go
index d98d9cd8a..4c266bc48 100644
--- a/tests/mocks/mock_index_repo_tests.go
+++ b/tests/mocks/mock_index_repo_tests.go
@@ -1,10 +1,10 @@
package mocks
import (
- "github.com/deluan/gosonic/domain"
- "fmt"
"encoding/json"
"errors"
+ "fmt"
+ "github.com/deluan/gosonic/domain"
)
func CreateMockArtistIndexRepo() *MockArtistIndex {
diff --git a/utils/index_group_parser.go b/utils/index_group_parser.go
index 7946fb55f..fad0137ca 100644
--- a/utils/index_group_parser.go
+++ b/utils/index_group_parser.go
@@ -1,20 +1,20 @@
-// Let's you specify how the index should look like.
-//
+// Let's you specify how the index should look like.
+//
// The specification is a space-separated list of index entries. Normally, each entry is just a single character,
// but you may also specify multiple characters. For instance, the entry "The" will link to all files and
-// folders starting with "The".
-//
+// folders starting with "The".
+//
// You may also create an entry using a group of index characters in paranthesis. For instance, the entry
// "A-E(ABCDE)" will display as "A-E" and link to all files and folders starting with either
// A, B, C, D or E. This may be useful for grouping less-frequently used characters (such and X, Y and Z), or
-// for grouping accented characters (such as A, \u00C0 and \u00C1)
-//
+// for grouping accented characters (such as A, \u00C0 and \u00C1)
+//
// Files and folders that are not covered by an index entry will be placed under the index entry "#".
package utils
import (
- "strings"
"regexp"
+ "strings"
)
type IndexGroups map[string]string
@@ -37,4 +37,4 @@ func ParseIndexGroups(spec string) IndexGroups {
}
}
return parsed
-}
\ No newline at end of file
+}
diff --git a/utils/mapping.go b/utils/mapping.go
index f950e900f..2eccadad0 100644
--- a/utils/mapping.go
+++ b/utils/mapping.go
@@ -3,8 +3,8 @@
package utils
import (
- "strconv"
"encoding/json"
+ "strconv"
)
const delimiter = "."
@@ -49,7 +49,7 @@ func flattenList(l []interface{}, parent string, delimiter string) (map[string]i
j[newkey] = value
}
default:
- // do nothing
+ // do nothing
}
}
return j, nil
@@ -92,7 +92,7 @@ func flattenMap(m map[string]interface{}, parent string, delimiter string) (map[
j[key] = value
}
default:
- //nothing
+ //nothing
}
}
return j, nil
@@ -110,7 +110,7 @@ func FlattenMap(input map[string]interface{}) (map[string]interface{}, error) {
func ToMap(rec interface{}) (map[string]interface{}, error) {
// Convert to JSON...
- b, err := json.Marshal(rec);
+ b, err := json.Marshal(rec)
if err != nil {
return nil, err
}
@@ -123,7 +123,7 @@ func ToMap(rec interface{}) (map[string]interface{}, error) {
func ToStruct(m map[string]interface{}, rec interface{}) error {
// Convert to JSON...
- b, err := json.Marshal(m);
+ b, err := json.Marshal(m)
if err != nil {
return err
}
diff --git a/utils/strings.go b/utils/strings.go
index 9c3eca8e8..155a52ee7 100644
--- a/utils/strings.go
+++ b/utils/strings.go
@@ -1,15 +1,15 @@
package utils
import (
- "strings"
"github.com/astaxie/beego"
+ "strings"
)
func NoArticle(name string) string {
articles := strings.Split(beego.AppConfig.String("ignoredArticles"), " ")
for _, a := range articles {
- n := strings.TrimPrefix(name, a + " ")
- if (n != name) {
+ n := strings.TrimPrefix(name, a+" ")
+ if n != name {
return n
}
}
diff --git a/utils/utils_test.go b/utils/utils_test.go
index 069aaa67e..16c747333 100644
--- a/utils/utils_test.go
+++ b/utils/utils_test.go
@@ -1,8 +1,8 @@
package utils
import (
- "testing"
. "github.com/smartystreets/goconvey/convey"
+ "testing"
)
func TestParseIndexGroup(t *testing.T) {
@@ -40,4 +40,4 @@ func TestParseIndexGroup(t *testing.T) {
So(parsed, ShouldContainKey, "æµ·")
So(parsed["æµ·"], ShouldEqual, "UTF8")
})
-}
\ No newline at end of file
+}