diff --git a/api/get_license.go b/api/get_license.go index 0bbc086f6..6db79dd56 100644 --- a/api/get_license.go +++ b/api/get_license.go @@ -11,6 +11,3 @@ func (c *GetLicenseController) Get() { response := responses.NewXML(&responses.License{Valid: true}) c.Ctx.Output.Body(response) } - - - diff --git a/api/get_music_folders.go b/api/get_music_folders.go index 8e209a39d..41a7237ad 100644 --- a/api/get_music_folders.go +++ b/api/get_music_folders.go @@ -20,6 +20,3 @@ func (c *GetMusicFoldersController) Get() { response := responses.NewXML(musicFolders) c.Ctx.Output.Body(response) } - - - diff --git a/api/ping.go b/api/ping.go index 8a6fa2092..3207deb75 100644 --- a/api/ping.go +++ b/api/ping.go @@ -1,8 +1,8 @@ package api import ( - "github.com/astaxie/beego" "encoding/xml" + "github.com/astaxie/beego" "github.com/deluan/gosonic/api/responses" ) @@ -13,6 +13,3 @@ func (c *PingController) Get() { xmlBody, _ := xml.Marshal(response) c.Ctx.Output.Body([]byte(xml.Header + string(xmlBody))) } - - - diff --git a/api/responses/error.go b/api/responses/error.go index b1b872331..040238236 100644 --- a/api/responses/error.go +++ b/api/responses/error.go @@ -32,9 +32,9 @@ func init() { } type error struct { - XMLName xml.Name`xml:"error"` - Code int `xml:"code,attr"` - Message string `xml:"message,attr"` + XMLName xml.Name `xml:"error"` + Code int `xml:"code,attr"` + Message string `xml:"message,attr"` } func NewError(errorCode int) []byte { @@ -47,4 +47,4 @@ func NewError(errorCode int) []byte { response.Body = xmlBody xmlResponse, _ := xml.Marshal(response) return []byte(xml.Header + string(xmlResponse)) -} \ No newline at end of file +} diff --git a/api/responses/license.go b/api/responses/license.go index f8d125e57..4920c1da1 100644 --- a/api/responses/license.go +++ b/api/responses/license.go @@ -4,5 +4,5 @@ import "encoding/xml" type License struct { XMLName xml.Name `xml:"license"` - Valid bool `xml:"valid,attr"` -} \ No newline at end of file + Valid bool `xml:"valid,attr"` +} diff --git a/api/responses/music_folders.go b/api/responses/music_folders.go index 868dc8f8b..2c7bbf63a 100644 --- a/api/responses/music_folders.go +++ b/api/responses/music_folders.go @@ -4,11 +4,11 @@ import "encoding/xml" type MusicFolder struct { XMLName xml.Name `xml:"musicFolder"` - Id string `xml:"id,attr"` - Name string `xml:"name,attr"` + Id string `xml:"id,attr"` + Name string `xml:"name,attr"` } type MusicFolders struct { - XMLName xml.Name `xml:"musicFolders"` + XMLName xml.Name `xml:"musicFolders"` Folders []MusicFolder `xml:"musicFolders"` -} \ No newline at end of file +} diff --git a/api/responses/subsonic.go b/api/responses/subsonic.go index f0c98c05c..1a03b42be 100644 --- a/api/responses/subsonic.go +++ b/api/responses/subsonic.go @@ -9,7 +9,7 @@ type Subsonic struct { XMLName xml.Name `xml:"http://subsonic.org/restapi subsonic-response"` Status string `xml:"status,attr"` Version string `xml:"version,attr"` - Body []byte `xml:",innerxml"` + Body []byte `xml:",innerxml"` } func NewEmpty() Subsonic { @@ -22,4 +22,4 @@ func NewXML(body interface{}) []byte { response.Body = xmlBody xmlResponse, _ := xml.Marshal(response) return []byte(xml.Header + string(xmlResponse)) -} \ No newline at end of file +} diff --git a/api/validation.go b/api/validation.go index de3d3dd83..096145edd 100644 --- a/api/validation.go +++ b/api/validation.go @@ -19,9 +19,9 @@ func Validate(controller ControllerInterface) { } func checkParameters(c ControllerInterface) { - requiredParameters := []string {"u", "p", "v", "c",} + requiredParameters := []string{"u", "p", "v", "c"} - for _,p := range requiredParameters { + for _, p := range requiredParameters { if c.GetString(p) == "" { cancel(c, responses.ERROR_MISSING_PARAMETER) } @@ -31,11 +31,11 @@ func checkParameters(c ControllerInterface) { func authenticate(c ControllerInterface) { user := c.GetString("u") pass := c.GetString("p") // TODO Handle hex-encoded password - if (user != beego.AppConfig.String("user") || pass != beego.AppConfig.String("password")) { + if user != beego.AppConfig.String("user") || pass != beego.AppConfig.String("password") { cancel(c, responses.ERROR_AUTHENTICATION_FAIL) } } func cancel(c ControllerInterface, code int) { c.CustomAbort(200, string(responses.NewError(code))) -} \ No newline at end of file +} diff --git a/controllers/main.go b/controllers/main.go index 05b1a6e69..21ff87d46 100644 --- a/controllers/main.go +++ b/controllers/main.go @@ -1,18 +1,16 @@ package controllers import ( - "github.com/astaxie/beego" "fmt" + "github.com/astaxie/beego" ) type MainController struct{ beego.Controller } - func (c *MainController) Get() { c.Ctx.Redirect(302, "/static/Jamstash/") } - func (c *MainController) Error404() { if beego.BConfig.RunMode == beego.DEV || beego.BConfig.Log.AccessLogs { r := c.Ctx.Request diff --git a/controllers/object.go b/controllers/object.go index 7c1ca5fd7..58647a728 100644 --- a/controllers/object.go +++ b/controllers/object.go @@ -1,8 +1,8 @@ package controllers import ( - "github.com/deluan/gosonic/models" "encoding/json" + "github.com/deluan/gosonic/models" "github.com/astaxie/beego" ) @@ -89,4 +89,3 @@ func (o *ObjectController) Delete() { o.Data["json"] = "delete success!" o.ServeJSON() } - diff --git a/controllers/user.go b/controllers/user.go index 89b833d3b..da894a453 100644 --- a/controllers/user.go +++ b/controllers/user.go @@ -1,8 +1,8 @@ package controllers import ( - "github.com/deluan/gosonic/models" "encoding/json" + "github.com/deluan/gosonic/models" "github.com/astaxie/beego" ) @@ -116,4 +116,3 @@ func (u *UserController) Logout() { u.Data["json"] = "logout success" u.ServeJSON() } - diff --git a/scanners/itunes/itl_scanner.go b/scanners/itunes/itl_scanner.go index ebf3f0bfb..b26e2b98d 100644 --- a/scanners/itunes/itl_scanner.go +++ b/scanners/itunes/itl_scanner.go @@ -1,16 +1,16 @@ package itunes import ( - "github.com/dhowden/itl" - "os" "github.com/deluan/gosonic/models" + "github.com/dhowden/itl" "net/url" -"strings" + "os" + "strings" ) func LoadFolder(path string) []models.MediaFile { xml, _ := os.Open(path) - l,_ := itl.ReadFromXML(xml) + l, _ := itl.ReadFromXML(xml) mediaFiles := make([]models.MediaFile, len(l.Tracks)) i := 0 @@ -19,7 +19,7 @@ func LoadFolder(path string) []models.MediaFile { mediaFiles[i].Album = track.Album mediaFiles[i].Title = track.Name mediaFiles[i].Artist = track.Artist - path,_ = url.QueryUnescape(track.Location) + path, _ = url.QueryUnescape(track.Location) mediaFiles[i].Path = strings.TrimPrefix(path, "file://") mediaFiles[i].CreatedAt = track.DateAdded mediaFiles[i].UpdatedAt = track.DateModified diff --git a/tests/api/get_license_test.go b/tests/api/get_license_test.go index 61f0aadd1..6c4ee16e3 100644 --- a/tests/api/get_license_test.go +++ b/tests/api/get_license_test.go @@ -1,11 +1,11 @@ package api_test import ( - "testing" + "encoding/xml" _ "github.com/deluan/gosonic/routers" . "github.com/deluan/gosonic/tests" - "encoding/xml" . "github.com/smartystreets/goconvey/convey" + "testing" ) func TestGetLicense(t *testing.T) { @@ -24,4 +24,3 @@ func TestGetLicense(t *testing.T) { }) } - diff --git a/tests/api/get_music_folders_test.go b/tests/api/get_music_folders_test.go index 48c92aaa5..7901bf220 100644 --- a/tests/api/get_music_folders_test.go +++ b/tests/api/get_music_folders_test.go @@ -1,12 +1,12 @@ package api_test import ( - "testing" _ "github.com/deluan/gosonic/routers" . "github.com/deluan/gosonic/tests" + "testing" - . "github.com/smartystreets/goconvey/convey" "encoding/xml" + . "github.com/smartystreets/goconvey/convey" ) func TestGetMusicFolders(t *testing.T) { @@ -24,4 +24,3 @@ func TestGetMusicFolders(t *testing.T) { }) }) } - diff --git a/tests/api/ping_test.go b/tests/api/ping_test.go index 8564e0c8d..4cda8086d 100644 --- a/tests/api/ping_test.go +++ b/tests/api/ping_test.go @@ -1,12 +1,12 @@ package api_test import ( - "testing" "encoding/xml" - _ "github.com/deluan/gosonic/routers" - . "github.com/smartystreets/goconvey/convey" "github.com/deluan/gosonic/api/responses" + _ "github.com/deluan/gosonic/routers" . "github.com/deluan/gosonic/tests" + . "github.com/smartystreets/goconvey/convey" + "testing" ) func TestPing(t *testing.T) { @@ -28,4 +28,3 @@ func TestPing(t *testing.T) { }) } - diff --git a/tests/api/validation_test.go b/tests/api/validation_test.go index 5fb5b2397..bb859ec50 100644 --- a/tests/api/validation_test.go +++ b/tests/api/validation_test.go @@ -1,12 +1,12 @@ package api_test import ( - "testing" "encoding/xml" + "github.com/deluan/gosonic/api/responses" _ "github.com/deluan/gosonic/routers" . "github.com/deluan/gosonic/tests" . "github.com/smartystreets/goconvey/convey" - "github.com/deluan/gosonic/api/responses" + "testing" ) func TestCheckParams(t *testing.T) { @@ -44,5 +44,3 @@ func TestAuthentication(t *testing.T) { }) }) } - - diff --git a/tests/test_helper.go b/tests/test_helper.go index 3db059c8d..b833f8ab6 100644 --- a/tests/test_helper.go +++ b/tests/test_helper.go @@ -3,23 +3,23 @@ package test import ( "fmt" "github.com/astaxie/beego" - "net/http/httptest" "net/http" + "net/http/httptest" + "os" "path/filepath" "runtime" - "os" ) const ( - testUser = "deluan" + testUser = "deluan" testPassword = "wordpass" - testClient = "test" - testVersion = "1.0.0" + testClient = "test" + testVersion = "1.0.0" ) func init() { _, file, _, _ := runtime.Caller(1) - appPath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator)))) + appPath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator)))) beego.TestBeegoInit(appPath) noLog := os.Getenv("NOLOG") @@ -41,4 +41,3 @@ func Get(url string, testCase string) (*http.Request, *httptest.ResponseRecorder return r, w } -