🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
go fmt
Deluane760952263f0
diff --git a/api/get_license.go b/api/get_license.goindex 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.goindex 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.goindex 8a6fa2092..3207deb75 100644--- a/api/ping.go+++ b/api/ping.go@@ -1,8 +1,8 @@package apiimport (- "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.goindex 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 = xmlBodyxmlResponse, _ := 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.goindex 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.goindex 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.goindex 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 = xmlBodyxmlResponse, _ := xml.Marshal(response)return []byte(xml.Header + string(xmlResponse))-}\ No newline at end of file+}diff --git a/api/validation.go b/api/validation.goindex 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.goindex 05b1a6e69..21ff87d46 100644--- a/controllers/main.go+++ b/controllers/main.go@@ -1,18 +1,16 @@package controllersimport (- "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.Requestdiff --git a/controllers/object.go b/controllers/object.goindex 7c1ca5fd7..58647a728 100644--- a/controllers/object.go+++ b/controllers/object.go@@ -1,8 +1,8 @@package controllersimport (- "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.goindex 89b833d3b..da894a453 100644--- a/controllers/user.go+++ b/controllers/user.go@@ -1,8 +1,8 @@package controllersimport (- "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.goindex ebf3f0bfb..b26e2b98d 100644--- a/scanners/itunes/itl_scanner.go+++ b/scanners/itunes/itl_scanner.go@@ -1,16 +1,16 @@package itunesimport (- "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.AlbummediaFiles[i].Title = track.NamemediaFiles[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.DateAddedmediaFiles[i].UpdatedAt = track.DateModifieddiff --git a/tests/api/get_license_test.go b/tests/api/get_license_test.goindex 61f0aadd1..6c4ee16e3 100644--- a/tests/api/get_license_test.go+++ b/tests/api/get_license_test.go@@ -1,11 +1,11 @@package api_testimport (- "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.goindex 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_testimport (- "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.goindex 8564e0c8d..4cda8086d 100644--- a/tests/api/ping_test.go+++ b/tests/api/ping_test.go@@ -1,12 +1,12 @@package api_testimport (- "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.goindex 5fb5b2397..bb859ec50 100644--- a/tests/api/validation_test.go+++ b/tests/api/validation_test.go@@ -1,12 +1,12 @@package api_testimport (- "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.goindex 3db059c8d..b833f8ab6 100644--- a/tests/test_helper.go+++ b/tests/test_helper.go@@ -3,23 +3,23 @@ package testimport ("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.ResponseRecorderreturn r, w}-