🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Remove dependency of deprecated `ioutil` package
Deluan8afa2cd833c4
diff --git a/core/agents/lastfm/agent_test.go b/core/agents/lastfm/agent_test.goindex f8ea2b370..68113eab4 100644--- a/core/agents/lastfm/agent_test.go+++ b/core/agents/lastfm/agent_test.go@@ -4,7 +4,7 @@ import ("bytes""context""errors"- "io/ioutil"+ "io""net/http""os""strconv"@@ -70,7 +70,7 @@ var _ = Describe("lastfmAgent", func() {})It("returns an error if Last.FM call returns an error", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError3)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError3)), StatusCode: 200}_, err := agent.GetBiography(ctx, "123", "U2", "mbid-1234")Expect(err).To(HaveOccurred())Expect(httpClient.RequestCount).To(Equal(1))@@ -78,7 +78,7 @@ var _ = Describe("lastfmAgent", func() {})It("returns an error if Last.FM call returns an error 6 and mbid is empty", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}_, err := agent.GetBiography(ctx, "123", "U2", "")Expect(err).To(HaveOccurred())Expect(httpClient.RequestCount).To(Equal(1))@@ -93,7 +93,7 @@ var _ = Describe("lastfmAgent", func() {Expect(httpClient.SavedRequest.URL.Query().Get("mbid")).To(BeEmpty())})It("calls again when last.fm returns an error 6", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}_, _ = agent.GetBiography(ctx, "123", "U2", "mbid-1234")Expect(httpClient.RequestCount).To(Equal(2))Expect(httpClient.SavedRequest.URL.Query().Get("mbid")).To(BeEmpty())@@ -131,7 +131,7 @@ var _ = Describe("lastfmAgent", func() {})It("returns an error if Last.FM call returns an error", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError3)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError3)), StatusCode: 200}_, err := agent.GetSimilar(ctx, "123", "U2", "mbid-1234", 2)Expect(err).To(HaveOccurred())Expect(httpClient.RequestCount).To(Equal(1))@@ -139,7 +139,7 @@ var _ = Describe("lastfmAgent", func() {})It("returns an error if Last.FM call returns an error 6 and mbid is empty", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}_, err := agent.GetSimilar(ctx, "123", "U2", "", 2)Expect(err).To(HaveOccurred())Expect(httpClient.RequestCount).To(Equal(1))@@ -154,7 +154,7 @@ var _ = Describe("lastfmAgent", func() {Expect(httpClient.SavedRequest.URL.Query().Get("mbid")).To(BeEmpty())})It("calls again when last.fm returns an error 6", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}_, _ = agent.GetSimilar(ctx, "123", "U2", "mbid-1234", 2)Expect(httpClient.RequestCount).To(Equal(2))Expect(httpClient.SavedRequest.URL.Query().Get("mbid")).To(BeEmpty())@@ -192,7 +192,7 @@ var _ = Describe("lastfmAgent", func() {})It("returns an error if Last.FM call returns an error", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError3)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError3)), StatusCode: 200}_, err := agent.GetTopSongs(ctx, "123", "U2", "mbid-1234", 2)Expect(err).To(HaveOccurred())Expect(httpClient.RequestCount).To(Equal(1))@@ -200,7 +200,7 @@ var _ = Describe("lastfmAgent", func() {})It("returns an error if Last.FM call returns an error 6 and mbid is empty", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}_, err := agent.GetTopSongs(ctx, "123", "U2", "", 2)Expect(err).To(HaveOccurred())Expect(httpClient.RequestCount).To(Equal(1))@@ -215,7 +215,7 @@ var _ = Describe("lastfmAgent", func() {Expect(httpClient.SavedRequest.URL.Query().Get("mbid")).To(BeEmpty())})It("calls again when last.fm returns an error 6", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString(lastfmError6)), StatusCode: 200}_, _ = agent.GetTopSongs(ctx, "123", "U2", "mbid-1234", 2)Expect(httpClient.RequestCount).To(Equal(2))Expect(httpClient.SavedRequest.URL.Query().Get("mbid")).To(BeEmpty())@@ -247,7 +247,7 @@ var _ = Describe("lastfmAgent", func() {Describe("NowPlaying", func() {It("calls Last.fm with correct params", func() {- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString("{}")), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString("{}")), StatusCode: 200}err := agent.NowPlaying(ctx, "user-1", track)@@ -274,7 +274,7 @@ var _ = Describe("lastfmAgent", func() {Describe("Scrobble", func() {It("calls Last.fm with correct params", func() {ts := time.Now()- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString("{}")), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString("{}")), StatusCode: 200}err := agent.Scrobble(ctx, "user-1", scrobbler.Scrobble{MediaFile: *track, TimeStamp: ts})@@ -295,7 +295,7 @@ var _ = Describe("lastfmAgent", func() {It("skips songs with less than 31 seconds", func() {track.Duration = 29- httpClient.Res = http.Response{Body: ioutil.NopCloser(bytes.NewBufferString("{}")), StatusCode: 200}+ httpClient.Res = http.Response{Body: io.NopCloser(bytes.NewBufferString("{}")), StatusCode: 200}err := agent.Scrobble(ctx, "user-1", scrobbler.Scrobble{MediaFile: *track, TimeStamp: time.Now()})@@ -310,7 +310,7 @@ var _ = Describe("lastfmAgent", func() {It("returns ErrRetryLater on error 11", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`{"error":11,"message":"Service Offline - This service is temporarily offline. Try again later."}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"error":11,"message":"Service Offline - This service is temporarily offline. Try again later."}`)),StatusCode: 400,}@@ -320,7 +320,7 @@ var _ = Describe("lastfmAgent", func() {It("returns ErrRetryLater on error 16", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`{"error":16,"message":"There was a temporary error processing your request. Please try again"}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"error":16,"message":"There was a temporary error processing your request. Please try again"}`)),StatusCode: 400,}@@ -330,7 +330,7 @@ var _ = Describe("lastfmAgent", func() {It("returns ErrRetryLater on http errors", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`internal server error`)),+ Body: io.NopCloser(bytes.NewBufferString(`internal server error`)),StatusCode: 500,}@@ -340,7 +340,7 @@ var _ = Describe("lastfmAgent", func() {It("returns ErrUnrecoverable on other errors", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`{"error":8,"message":"Operation failed - Something else went wrong"}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"error":8,"message":"Operation failed - Something else went wrong"}`)),StatusCode: 400,}diff --git a/core/agents/lastfm/client_test.go b/core/agents/lastfm/client_test.goindex cdd707d36..79bb44830 100644--- a/core/agents/lastfm/client_test.go+++ b/core/agents/lastfm/client_test.go@@ -6,7 +6,7 @@ import ("crypto/md5""errors""fmt"- "io/ioutil"+ "io""net/http""net/url""os"@@ -38,7 +38,7 @@ var _ = Describe("Client", func() {It("fails if Last.FM returns an http status != 200", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`Internal Server Error`)),+ Body: io.NopCloser(bytes.NewBufferString(`Internal Server Error`)),StatusCode: 500,}@@ -48,7 +48,7 @@ var _ = Describe("Client", func() {It("fails if Last.FM returns an http status != 200", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`{"error":3,"message":"Invalid Method - No method with that name in this package"}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"error":3,"message":"Invalid Method - No method with that name in this package"}`)),StatusCode: 400,}@@ -58,7 +58,7 @@ var _ = Describe("Client", func() {It("fails if Last.FM returns an error", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`{"error":6,"message":"The artist you supplied could not be found"}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"error":6,"message":"The artist you supplied could not be found"}`)),StatusCode: 200,}@@ -75,7 +75,7 @@ var _ = Describe("Client", func() {It("fails if returned body is not a valid JSON", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`<xml>NOT_VALID_JSON</xml>`)),+ Body: io.NopCloser(bytes.NewBufferString(`<xml>NOT_VALID_JSON</xml>`)),StatusCode: 200,}@@ -112,7 +112,7 @@ var _ = Describe("Client", func() {Describe("GetToken", func() {It("returns a token when the request is successful", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`{"token":"TOKEN"}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"token":"TOKEN"}`)),StatusCode: 200,}@@ -128,7 +128,7 @@ var _ = Describe("Client", func() {Describe("GetSession", func() {It("returns a session key when the request is successful", func() {httpClient.Res = http.Response{- Body: ioutil.NopCloser(bytes.NewBufferString(`{"session":{"name":"Navidrome","key":"SESSION_KEY","subscriber":0}}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"session":{"name":"Navidrome","key":"SESSION_KEY","subscriber":0}}`)),StatusCode: 200,}diff --git a/core/agents/lastfm/responses_test.go b/core/agents/lastfm/responses_test.goindex 96580bad3..62b2aae1a 100644--- a/core/agents/lastfm/responses_test.go+++ b/core/agents/lastfm/responses_test.go@@ -2,7 +2,7 @@ package lastfmimport ("encoding/json"- "io/ioutil"+ "os". "github.com/onsi/ginkgo". "github.com/onsi/gomega"@@ -12,7 +12,7 @@ var _ = Describe("LastFM responses", func() {Describe("Artist", func() {It("parses the response correctly", func() {var resp Response- body, _ := ioutil.ReadFile("tests/fixtures/lastfm.artist.getinfo.json")+ body, _ := os.ReadFile("tests/fixtures/lastfm.artist.getinfo.json")err := json.Unmarshal(body, &resp)Expect(err).To(BeNil())@@ -26,7 +26,7 @@ var _ = Describe("LastFM responses", func() {Describe("SimilarArtists", func() {It("parses the response correctly", func() {var resp Response- body, _ := ioutil.ReadFile("tests/fixtures/lastfm.artist.getsimilar.json")+ body, _ := os.ReadFile("tests/fixtures/lastfm.artist.getsimilar.json")err := json.Unmarshal(body, &resp)Expect(err).To(BeNil())@@ -39,7 +39,7 @@ var _ = Describe("LastFM responses", func() {Describe("TopTracks", func() {It("parses the response correctly", func() {var resp Response- body, _ := ioutil.ReadFile("tests/fixtures/lastfm.artist.gettoptracks.json")+ body, _ := os.ReadFile("tests/fixtures/lastfm.artist.gettoptracks.json")err := json.Unmarshal(body, &resp)Expect(err).To(BeNil())diff --git a/core/agents/spotify/client.go b/core/agents/spotify/client.goindex f1e22fa8b..8361a9887 100644--- a/core/agents/spotify/client.go+++ b/core/agents/spotify/client.go@@ -6,7 +6,7 @@ import ("encoding/json""errors""fmt"- "io/ioutil"+ "io""net/http""net/url""strconv"@@ -93,7 +93,7 @@ func (c *Client) makeRequest(req *http.Request, response interface{}) error {}defer resp.Body.Close()- data, err := ioutil.ReadAll(resp.Body)+ data, err := io.ReadAll(resp.Body)if err != nil {return err}diff --git a/core/agents/spotify/client_test.go b/core/agents/spotify/client_test.goindex af49736b6..afce3bdeb 100644--- a/core/agents/spotify/client_test.go+++ b/core/agents/spotify/client_test.go@@ -3,7 +3,7 @@ package spotifyimport ("bytes""context"- "io/ioutil"+ "io""net/http""os"@@ -26,7 +26,7 @@ var _ = Describe("Client", func() {httpClient.mock("https://api.spotify.com/v1/search", http.Response{Body: f, StatusCode: 200})httpClient.mock("https://accounts.spotify.com/api/token", http.Response{StatusCode: 200,- Body: ioutil.NopCloser(bytes.NewBufferString(`{"access_token": "NEW_ACCESS_TOKEN","token_type": "Bearer","expires_in": 3600}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"access_token": "NEW_ACCESS_TOKEN","token_type": "Bearer","expires_in": 3600}`)),})artists, err := client.SearchArtists(context.TODO(), "U2", 10)@@ -44,7 +44,7 @@ var _ = Describe("Client", func() {It("fails if artist was not found", func() {httpClient.mock("https://api.spotify.com/v1/search", http.Response{StatusCode: 200,- Body: ioutil.NopCloser(bytes.NewBufferString(`{+ Body: io.NopCloser(bytes.NewBufferString(`{"artists" : {"href" : "https://api.spotify.com/v1/search?query=dasdasdas%2Cdna&type=artist&offset=0&limit=20","items" : [ ], "limit" : 20, "next" : null, "offset" : 0, "previous" : null, "total" : 0@@ -52,7 +52,7 @@ var _ = Describe("Client", func() {})httpClient.mock("https://accounts.spotify.com/api/token", http.Response{StatusCode: 200,- Body: ioutil.NopCloser(bytes.NewBufferString(`{"access_token": "NEW_ACCESS_TOKEN","token_type": "Bearer","expires_in": 3600}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"access_token": "NEW_ACCESS_TOKEN","token_type": "Bearer","expires_in": 3600}`)),})_, err := client.SearchArtists(context.TODO(), "U2", 10)@@ -64,7 +64,7 @@ var _ = Describe("Client", func() {httpClient.mock("https://api.spotify.com/v1/search", http.Response{Body: f, StatusCode: 200})httpClient.mock("https://accounts.spotify.com/api/token", http.Response{StatusCode: 400,- Body: ioutil.NopCloser(bytes.NewBufferString(`{"error":"invalid_client","error_description":"Invalid client"}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"error":"invalid_client","error_description":"Invalid client"}`)),})_, err := client.SearchArtists(context.TODO(), "U2", 10)@@ -76,7 +76,7 @@ var _ = Describe("Client", func() {It("returns an access_token on successful authorization", func() {httpClient.mock("https://accounts.spotify.com/api/token", http.Response{StatusCode: 200,- Body: ioutil.NopCloser(bytes.NewBufferString(`{"access_token": "NEW_ACCESS_TOKEN","token_type": "Bearer","expires_in": 3600}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"access_token": "NEW_ACCESS_TOKEN","token_type": "Bearer","expires_in": 3600}`)),})token, err := client.authorize(context.TODO())@@ -89,7 +89,7 @@ var _ = Describe("Client", func() {It("fails on unsuccessful authorization", func() {httpClient.mock("https://accounts.spotify.com/api/token", http.Response{StatusCode: 400,- Body: ioutil.NopCloser(bytes.NewBufferString(`{"error":"invalid_client","error_description":"Invalid client"}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{"error":"invalid_client","error_description":"Invalid client"}`)),})_, err := client.authorize(context.TODO())@@ -99,7 +99,7 @@ var _ = Describe("Client", func() {It("fails on invalid JSON response", func() {httpClient.mock("https://accounts.spotify.com/api/token", http.Response{StatusCode: 200,- Body: ioutil.NopCloser(bytes.NewBufferString(`{NOT_VALID}`)),+ Body: io.NopCloser(bytes.NewBufferString(`{NOT_VALID}`)),})_, err := client.authorize(context.TODO())diff --git a/core/agents/spotify/responses_test.go b/core/agents/spotify/responses_test.goindex 8909f71e1..f8bcfb1b5 100644--- a/core/agents/spotify/responses_test.go+++ b/core/agents/spotify/responses_test.go@@ -2,7 +2,7 @@ package spotifyimport ("encoding/json"- "io/ioutil"+ "os". "github.com/onsi/ginkgo". "github.com/onsi/gomega"@@ -12,7 +12,7 @@ var _ = Describe("Responses", func() {Describe("Search type=artist", func() {It("parses the artist search result correctly ", func() {var resp SearchResults- body, _ := ioutil.ReadFile("tests/fixtures/spotify.search.artist.json")+ body, _ := os.ReadFile("tests/fixtures/spotify.search.artist.json")err := json.Unmarshal(body, &resp)Expect(err).To(BeNil())diff --git a/core/artwork.go b/core/artwork.goindex 665c6df08..ae872443e 100644--- a/core/artwork.go+++ b/core/artwork.go@@ -10,7 +10,6 @@ import ("image/jpeg"_ "image/png""io"- "io/ioutil""os""strings""sync"@@ -173,7 +172,7 @@ func resizeImage(reader io.Reader, size int) (io.ReadCloser, error) {buf := new(bytes.Buffer)err = jpeg.Encode(buf, m, &jpeg.Options{Quality: conf.Server.CoverJpegQuality})- return ioutil.NopCloser(buf), err+ return io.NopCloser(buf), err}func readFromTag(path string) (io.ReadCloser, error) {@@ -192,7 +191,7 @@ func readFromTag(path string) (io.ReadCloser, error) {if picture == nil {return nil, errors.New("file does not contain embedded art")}- return ioutil.NopCloser(bytes.NewReader(picture.Data)), nil+ return io.NopCloser(bytes.NewReader(picture.Data)), nil}func readFromFile(path string) (io.ReadCloser, error) {diff --git a/core/artwork_test.go b/core/artwork_test.goindex 6ebbfe686..936bf69b3 100644--- a/core/artwork_test.go+++ b/core/artwork_test.go@@ -3,7 +3,7 @@ package coreimport ("context""image"- "io/ioutil"+ "os""github.com/navidrome/navidrome/conf""github.com/navidrome/navidrome/log"@@ -33,7 +33,7 @@ var _ = Describe("Artwork", func() {Context("Cache is configured", func() {BeforeEach(func() {- conf.Server.DataFolder, _ = ioutil.TempDir("", "file_caches")+ conf.Server.DataFolder, _ = os.MkdirTemp("", "file_caches")conf.Server.ImageCacheSize = "100MB"cache := GetImageCache()Eventually(func() bool { return cache.Ready(context.TODO()) }).Should(BeTrue())diff --git a/core/cache_warmer.go b/core/cache_warmer.goindex 47370a92d..72368f81a 100644--- a/core/cache_warmer.go+++ b/core/cache_warmer.go@@ -3,7 +3,6 @@ package coreimport ("context""io"- "io/ioutil""time""github.com/navidrome/navidrome/conf"@@ -80,7 +79,7 @@ func (w *warmer) execute(workload interface{}) {return}defer r.Close()- _, _ = io.Copy(ioutil.Discard, r)+ _, _ = io.Copy(io.Discard, r)}type artworkItem struct {diff --git a/core/media_streamer_test.go b/core/media_streamer_test.goindex b59191572..04a663243 100644--- a/core/media_streamer_test.go+++ b/core/media_streamer_test.go@@ -3,7 +3,7 @@ package coreimport ("context""io"- "io/ioutil"+ "os""strings""github.com/navidrome/navidrome/conf"@@ -22,7 +22,7 @@ var _ = Describe("MediaStreamer", func() {ctx := log.NewContext(context.TODO())BeforeEach(func() {- conf.Server.DataFolder, _ = ioutil.TempDir("", "file_caches")+ conf.Server.DataFolder, _ = os.MkdirTemp("", "file_caches")conf.Server.TranscodingCacheSize = "100MB"ds = &tests.MockDataStore{MockedTranscoding: &tests.MockTranscodingRepo{}}ds.MediaFile(ctx).(*tests.MockMediaFileRepo).SetData(model.MediaFiles{@@ -58,7 +58,7 @@ var _ = Describe("MediaStreamer", func() {It("returns a seekable stream if the file is complete in the cache", func() {s, err := streamer.NewStream(ctx, "123", "mp3", 32)Expect(err).To(BeNil())- _, _ = ioutil.ReadAll(s)+ _, _ = io.ReadAll(s)_ = s.Close()Eventually(func() bool { return ffmpeg.closed }, "3s").Should(BeTrue())diff --git a/persistence/album_repository_test.go b/persistence/album_repository_test.goindex cd55e6570..c05bb104d 100644--- a/persistence/album_repository_test.go+++ b/persistence/album_repository_test.go@@ -2,7 +2,6 @@ package persistenceimport ("context"- "io/ioutil""os""path/filepath"@@ -89,7 +88,7 @@ var _ = Describe("AlbumRepository", func() {})Describe("getCoverFromPath", func() {- testFolder, _ := ioutil.TempDir("", "album_persistence_tests")+ testFolder, _ := os.MkdirTemp("", "album_persistence_tests")if err := os.MkdirAll(testFolder, 0777); err != nil {panic(err)}diff --git a/resources/embed.go b/resources/embed.goindex 13c5d2588..4228d5522 100644--- a/resources/embed.go+++ b/resources/embed.go@@ -2,7 +2,7 @@ package resourcesimport ("embed"- "io/ioutil"+ "io")//go:embed *@@ -13,5 +13,5 @@ func Asset(path string) ([]byte, error) {if err != nil {return nil, err}- return ioutil.ReadAll(f)+ return io.ReadAll(f)}diff --git a/scanner/playlist_sync.go b/scanner/playlist_sync.goindex 955e0ab7d..50bebfc40 100644--- a/scanner/playlist_sync.go+++ b/scanner/playlist_sync.go@@ -5,7 +5,6 @@ import ("bytes""context""fmt"- "io/ioutil""os""path/filepath""strings"@@ -26,7 +25,7 @@ func newPlaylistSync(ds model.DataStore) *playlistSync {func (s *playlistSync) processPlaylists(ctx context.Context, dir string) int64 {var count int64- files, err := ioutil.ReadDir(dir)+ files, err := os.ReadDir(dir)if err != nil {log.Error(ctx, "Error reading files", "dir", dir, err)return countdiff --git a/server/nativeapi/translations.go b/server/nativeapi/translations.goindex 93f738f42..2b87fa821 100644--- a/server/nativeapi/translations.go+++ b/server/nativeapi/translations.go@@ -4,8 +4,8 @@ import ("bytes""context""encoding/json"+ "io""io/fs"- "io/ioutil""os""path/filepath""strings"@@ -112,7 +112,7 @@ func loadTranslation(fsys fs.FS, fileName string) (translation translation, errif err != nil {return}- data, err := ioutil.ReadAll(file)+ data, err := io.ReadAll(file)if err != nil {return}diff --git a/server/nativeapi/translations_test.go b/server/nativeapi/translations_test.goindex 8e4f9aaf4..4e99b3200 100644--- a/server/nativeapi/translations_test.go+++ b/server/nativeapi/translations_test.go@@ -2,7 +2,7 @@ package nativeapiimport ("encoding/json"- "io/ioutil"+ "io""net/http""os""path/filepath"@@ -26,7 +26,7 @@ var _ = Describe("Translations", func() {name := filepath.Base(f.Name())filePath := filepath.Join(consts.I18nFolder, name)file, _ := fs.Open(filePath)- data, _ := ioutil.ReadAll(file)+ data, _ := io.ReadAll(file)var out map[string]interface{}Expect(filepath.Ext(filePath)).To(Equal(".json"), filePath)diff --git a/server/serve_index.go b/server/serve_index.goindex 1bafe505b..204633dc0 100644--- a/server/serve_index.go+++ b/server/serve_index.go@@ -3,8 +3,8 @@ package serverimport ("encoding/json""html/template"+ "io""io/fs"- "io/ioutil""net/http""strings"@@ -82,7 +82,7 @@ func getIndexTemplate(r *http.Request, fs fs.FS) (*template.Template, error) {log.Error(r, "Could not find `index.html` template", err)return nil, err}- indexStr, err := ioutil.ReadAll(indexHtml)+ indexStr, err := io.ReadAll(indexHtml)if err != nil {log.Error(r, "Could not read from `index.html`", err)return nil, errdiff --git a/server/subsonic/media_retrieval_test.go b/server/subsonic/media_retrieval_test.goindex 46cd23b57..705e52d18 100644--- a/server/subsonic/media_retrieval_test.go+++ b/server/subsonic/media_retrieval_test.go@@ -5,7 +5,6 @@ import ("context""errors""io"- "io/ioutil""net/http/httptest""github.com/navidrome/navidrome/model"@@ -76,5 +75,5 @@ func (c *fakeArtwork) Get(ctx context.Context, id string, size int) (io.ReadClos}c.recvId = idc.recvSize = size- return ioutil.NopCloser(bytes.NewReader([]byte(c.data))), nil+ return io.NopCloser(bytes.NewReader([]byte(c.data))), nil}diff --git a/server/subsonic/stream.go b/server/subsonic/stream.goindex 462ccee4f..5f0859aff 100644--- a/server/subsonic/stream.go+++ b/server/subsonic/stream.go@@ -3,7 +3,6 @@ package subsonicimport ("fmt""io"- "io/ioutil""net/http""strconv""strings"@@ -67,7 +66,7 @@ func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*resp}if r.Method == "HEAD" {- go func() { _, _ = io.Copy(ioutil.Discard, stream) }()+ go func() { _, _ = io.Copy(io.Discard, stream) }()} else {if c, err := io.Copy(w, stream); err != nil {log.Error(ctx, "Error sending transcoded file", "id", id, err)diff --git a/utils/cache/file_caches_test.go b/utils/cache/file_caches_test.goindex c8f94cd06..f6408e173 100644--- a/utils/cache/file_caches_test.go+++ b/utils/cache/file_caches_test.go@@ -3,7 +3,6 @@ package cacheimport ("context""io"- "io/ioutil""os""path/filepath""strings"@@ -22,7 +21,7 @@ func callNewFileCache(name, cacheSize, cacheFolder string, maxItems int, getReadvar _ = Describe("File Caches", func() {BeforeEach(func() {- conf.Server.DataFolder, _ = ioutil.TempDir("", "file_caches")+ conf.Server.DataFolder, _ = os.MkdirTemp("", "file_caches")})AfterEach(func() {os.RemoveAll(conf.Server.DataFolder)@@ -61,13 +60,13 @@ var _ = Describe("File Caches", func() {Expect(err).To(BeNil())Expect(s.Cached).To(BeFalse())Expect(s.Closer).To(BeNil())- Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))+ Expect(io.ReadAll(s)).To(Equal([]byte("test")))// Second call is a HITcalled = falses, err = fc.Get(context.TODO(), &testArg{"test"})Expect(err).To(BeNil())- Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))+ Expect(io.ReadAll(s)).To(Equal([]byte("test")))Expect(s.Cached).To(BeTrue())Expect(s.Closer).ToNot(BeNil())Expect(called).To(BeFalse())@@ -83,13 +82,13 @@ var _ = Describe("File Caches", func() {s, err := fc.Get(context.TODO(), &testArg{"test"})Expect(err).To(BeNil())Expect(s.Cached).To(BeFalse())- Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))+ Expect(io.ReadAll(s)).To(Equal([]byte("test")))// Second call is also a MISScalled = falses, err = fc.Get(context.TODO(), &testArg{"test"})Expect(err).To(BeNil())- Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))+ Expect(io.ReadAll(s)).To(Equal([]byte("test")))Expect(s.Cached).To(BeFalse())Expect(called).To(BeTrue())})diff --git a/utils/cache/spread_fs_test.go b/utils/cache/spread_fs_test.goindex 2b821d064..cad185deb 100644--- a/utils/cache/spread_fs_test.go+++ b/utils/cache/spread_fs_test.go@@ -1,7 +1,6 @@package cacheimport (- "io/ioutil""os""path/filepath""strings"@@ -16,7 +15,7 @@ var _ = Describe("Spread FS", func() {BeforeEach(func() {var err error- rootDir, _ = ioutil.TempDir("", "spread_fs")+ rootDir, _ = os.MkdirTemp("", "spread_fs")fs, err = NewSpreadFS(rootDir, 0755)Expect(err).To(BeNil())})@@ -54,7 +53,7 @@ var _ = Describe("Spread FS", func() {var actual []stringerr := fs.Reload(func(key string, name string) {Expect(key).To(Equal(name))- data, err := ioutil.ReadFile(name)+ data, err := os.ReadFile(name)Expect(err).To(BeNil())actual = append(actual, string(data))})diff --git a/utils/cached_http_client.go b/utils/cached_http_client.goindex c8acc1785..c0b4d8007 100644--- a/utils/cached_http_client.go+++ b/utils/cached_http_client.go@@ -6,7 +6,6 @@ import ("encoding/base64""encoding/json""io"- "io/ioutil""net/http""strings""time"@@ -71,7 +70,7 @@ func (c *CachedHTTPClient) serializeReq(req *http.Request) string {URL: req.URL.String(),}if req.Body != nil {- bodyData, _ := ioutil.ReadAll(req.Body)+ bodyData, _ := io.ReadAll(req.Body)bodyStr := base64.StdEncoding.EncodeToString(bodyData)data.Body = &bodyStr}diff --git a/utils/cached_http_client_test.go b/utils/cached_http_client_test.goindex 71263b9e9..e927e4ff3 100644--- a/utils/cached_http_client_test.go+++ b/utils/cached_http_client_test.go@@ -2,7 +2,7 @@ package utilsimport ("fmt"- "io/ioutil"+ "io""net/http""net/http/httptest""time"@@ -36,7 +36,7 @@ var _ = Describe("CachedHttpClient", func() {r, _ := http.NewRequest("GET", ts.URL+"?name=doe", nil)resp, err := chc.Do(r)Expect(err).To(BeNil())- body, err := ioutil.ReadAll(resp.Body)+ body, err := io.ReadAll(resp.Body)Expect(err).To(BeNil())Expect(string(body)).To(Equal("Hello, [doe]"))Expect(requestsReceived).To(Equal(1))@@ -45,7 +45,7 @@ var _ = Describe("CachedHttpClient", func() {r, _ = http.NewRequest("GET", ts.URL+"?name=doe", nil)resp, err = chc.Do(r)Expect(err).To(BeNil())- body, err = ioutil.ReadAll(resp.Body)+ body, err = io.ReadAll(resp.Body)Expect(err).To(BeNil())Expect(string(body)).To(Equal("Hello, [doe]"))Expect(requestsReceived).To(Equal(1))@@ -54,7 +54,7 @@ var _ = Describe("CachedHttpClient", func() {r, _ = http.NewRequest("GET", ts.URL, nil)resp, err = chc.Do(r)Expect(err).To(BeNil())- body, err = ioutil.ReadAll(resp.Body)+ body, err = io.ReadAll(resp.Body)Expect(err).To(BeNil())Expect(string(body)).To(Equal("Hello, []"))Expect(requestsReceived).To(Equal(2))@@ -64,7 +64,7 @@ var _ = Describe("CachedHttpClient", func() {r.Header.Add("head", "this is a header")resp, err = chc.Do(r)Expect(err).To(BeNil())- body, err = ioutil.ReadAll(resp.Body)+ body, err = io.ReadAll(resp.Body)Expect(err).To(BeNil())Expect(string(body)).To(Equal("Hello, []"))Expect(header).To(Equal("this is a header"))diff --git a/utils/merge_fs_test.go b/utils/merge_fs_test.goindex cefd9c998..7aab37bd9 100644--- a/utils/merge_fs_test.go+++ b/utils/merge_fs_test.go@@ -1,8 +1,8 @@package utils_testimport (+ "io""io/fs"- "io/ioutil""os""path/filepath"@@ -16,8 +16,8 @@ var _ = Describe("MergeFS", func() {var baseDir, overlayDir, mergedDir fs.FSBeforeEach(func() {- baseName, _ = ioutil.TempDir("", "merge_fs_base_test")- overlayName, _ = ioutil.TempDir("", "merge_fs_overlay_test")+ baseName, _ = os.MkdirTemp("", "merge_fs_base_test")+ overlayName, _ = os.MkdirTemp("", "merge_fs_overlay_test")baseDir = os.DirFS(baseName)overlayDir = os.DirFS(overlayName)mergedDir = utils.MergeFS{Base: baseDir, Overlay: overlayDir}@@ -41,7 +41,7 @@ var _ = Describe("MergeFS", func() {file, err := mergedDir.Open("b.json")Expect(err).To(BeNil())- content, err := ioutil.ReadAll(file)+ content, err := io.ReadAll(file)Expect(err).To(BeNil())Expect(string(content)).To(Equal("overridden"))})