Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/codetests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.9
version: v2.11
# Runs golangci-lint on linux against linux and windows.
golangci-linux:
strategy:
Expand All @@ -67,4 +67,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.9
version: v2.11
23 changes: 1 addition & 22 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ linters:
- tagliatelle
- noinlineerr
- wsl
# fix these
- modernize
- perfsprint
- godoclint
settings:
wsl_v5:
allow-first-in-block: true
Expand All @@ -28,17 +24,9 @@ linters:
- github.com/stretchr/testify
- golift.io/starr
- golang.org/x/net
ireturn:
allow:
- generic
- stdlib
- error
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
Expand All @@ -51,10 +39,7 @@ linters:
- lll
- maintidx
path: (.+)_test\.go
paths:
- third_party$
- builtin$
- examples$

issues:
max-issues-per-linter: 0
max-same-issues: 0
Expand All @@ -64,9 +49,3 @@ formatters:
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
10 changes: 5 additions & 5 deletions debuglog/roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// Config is the input data for the logger.
type Config struct {
// This is where logs go. If not set they go to log.Printf.
Debugf func(string, ...interface{})
Debugf func(string, ...any)
// This can be used for byte counters, but is optional otherwise.
Caller Caller
// Any strings in this list are replaced with <recated> in the log output.
Expand Down Expand Up @@ -156,18 +156,18 @@ func (f *fakeCloser) logRequest() (int, int) {
}

func (f *fakeCloser) headers() string {
var headers string
var headers strings.Builder

for header, values := range f.Header {
for _, value := range values {
headers += header + ": " + value + "\n"
headers.WriteString(header + ": " + value + "\n")
}
}

return headers
return headers.String()
}

func (f *fakeCloser) redactLog(msg string, format ...interface{}) {
func (f *fakeCloser) redactLog(msg string, format ...any) {
msg = fmt.Sprintf(msg, format...)

for _, redact := range f.Redact {
Expand Down
4 changes: 2 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func parseNon200(resp *http.Response) *ReqError {
func closeResp(resp *http.Response) {
if resp != nil && resp.Body != nil {
_, _ = io.ReadAll(resp.Body)
resp.Body.Close()
_ = resp.Body.Close()
}
}

Expand All @@ -148,7 +148,7 @@ func (c *Config) SetHeaders(req *http.Request) {
req.Header.Set("Accept", "application/json")
}

req.Header.Set("User-Agent", "go-starr: https://"+reflect.TypeOf(Config{}).PkgPath())
req.Header.Set("User-Agent", "go-starr: https://"+reflect.TypeFor[Config]().PkgPath())
req.Header.Set("X-Api-Key", c.APIKey)
}

Expand Down
16 changes: 8 additions & 8 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ type APIer interface {
Put(ctx context.Context, req Request) (*http.Response, error) // Put request; Params should contain io.Reader.
Delete(ctx context.Context, req Request) (*http.Response, error) // Delete request; Params are optional.
// Normal data, unmarshals into provided interface. Use these because they close the response body.
GetInto(ctx context.Context, req Request, output interface{}) error // API GET Request.
PostInto(ctx context.Context, req Request, output interface{}) error // API POST Request.
PutInto(ctx context.Context, req Request, output interface{}) error // API PUT Request.
DeleteAny(ctx context.Context, req Request) error // API Delete request.
GetInto(ctx context.Context, req Request, output any) error // API GET Request.
PostInto(ctx context.Context, req Request, output any) error // API POST Request.
PutInto(ctx context.Context, req Request, output any) error // API PUT Request.
DeleteAny(ctx context.Context, req Request) error // API Delete request.
}

// Config must satisfy the APIer struct.
Expand Down Expand Up @@ -116,21 +116,21 @@ func (c *Config) Delete(ctx context.Context, req Request) (*http.Response, error

// GetInto performs an HTTP GET against an API path and
// unmarshals the payload into the provided pointer interface.
func (c *Config) GetInto(ctx context.Context, req Request, output interface{}) error {
func (c *Config) GetInto(ctx context.Context, req Request, output any) error {
resp, err := c.api(ctx, http.MethodGet, req)
return decode(output, resp, err)
}

// PostInto performs an HTTP POST against an API path and
// unmarshals the payload into the provided pointer interface.
func (c *Config) PostInto(ctx context.Context, req Request, output interface{}) error {
func (c *Config) PostInto(ctx context.Context, req Request, output any) error {
resp, err := c.api(ctx, http.MethodPost, req)
return decode(output, resp, err)
}

// PutInto performs an HTTP PUT against an API path and
// unmarshals the payload into the provided pointer interface.
func (c *Config) PutInto(ctx context.Context, req Request, output interface{}) error {
func (c *Config) PutInto(ctx context.Context, req Request, output any) error {
resp, err := c.api(ctx, http.MethodPut, req)
return decode(output, resp, err)
}
Expand All @@ -144,7 +144,7 @@ func (c *Config) DeleteAny(ctx context.Context, req Request) error {
}

// decode is an extra procedure to check an error and decode the JSON resp.Body payload.
func decode(output interface{}, resp *http.Response, err error) error {
func decode(output any, resp *http.Response, err error) error {
if err != nil {
return err
} else if output == nil {
Expand Down
2 changes: 1 addition & 1 deletion lidarr/album.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Album struct {
ProfileID int64 `json:"profileId"`
Duration int `json:"duration"`
AlbumType string `json:"albumType"`
SecondaryTypes []interface{} `json:"secondaryTypes"`
SecondaryTypes []any `json:"secondaryTypes"`
MediumCount int `json:"mediumCount"`
Ratings *starr.Ratings `json:"ratings"`
ReleaseDate time.Time `json:"releaseDate"`
Expand Down
4 changes: 2 additions & 2 deletions lidarr/artist.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const bpArtist = APIver + "/artist"
type Artist struct {
ID int64 `json:"id"`
Status string `json:"status,omitempty"`
LastInfoSync time.Time `json:"lastInfoSync,omitempty"`
LastInfoSync time.Time `json:"lastInfoSync,omitzero"`
ArtistName string `json:"artistName,omitempty"`
ForeignArtistID string `json:"foreignArtistId,omitempty"`
TadbID int64 `json:"tadbId,omitempty"`
Expand All @@ -36,7 +36,7 @@ type Artist struct {
Images []*starr.Image `json:"images,omitempty"`
Genres []string `json:"genres,omitempty"`
Tags []int `json:"tags,omitempty"`
Added time.Time `json:"added,omitempty"`
Added time.Time `json:"added,omitzero"`
Ratings *starr.Ratings `json:"ratings,omitempty"`
Statistics *Statistics `json:"statistics,omitempty"`
LastAlbum *Album `json:"lastAlbum,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion lidarr/blocklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type BlockList struct {
type BlockListRecord struct {
Artist *Artist `json:"artist"`
Quality *starr.Quality `json:"quality"`
CustomFormats []interface{} `json:"customFormats"`
CustomFormats []any `json:"customFormats"`
AlbumIDs []int64 `json:"albumIds"`
ID int64 `json:"id"`
ArtistID int64 `json:"artistId"`
Expand Down
2 changes: 1 addition & 1 deletion lidarr/calendar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var testCalendarStruct = lidarr.Album{
ArtistID: 163,
ForeignAlbumID: "95b28969-3252-45a7-9e1b-b2d8f59eee45",
ProfileID: 3,
SecondaryTypes: []interface{}{},
SecondaryTypes: []any{},
Duration: 3897000,
AlbumType: "Album",
MediumCount: 1,
Expand Down
8 changes: 4 additions & 4 deletions lidarr/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ type CommandResponse struct {
Priority string `json:"priority"`
Status string `json:"status"`
Queued time.Time `json:"queued"`
Started time.Time `json:"started,omitempty"`
Ended time.Time `json:"ended,omitempty"`
StateChangeTime time.Time `json:"stateChangeTime,omitempty"`
LastExecutionTime time.Time `json:"lastExecutionTime,omitempty"`
Started time.Time `json:"started,omitzero"`
Ended time.Time `json:"ended,omitzero"`
StateChangeTime time.Time `json:"stateChangeTime,omitzero"`
LastExecutionTime time.Time `json:"lastExecutionTime,omitzero"`
Duration string `json:"duration,omitempty"`
Trigger string `json:"trigger"`
SendUpdatesToClient bool `json:"sendUpdatesToClient"`
Expand Down
4 changes: 2 additions & 2 deletions lidarr/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestGetCommands(t *testing.T) {
Trigger: "someTrigger",
SendUpdatesToClient: true,
UpdateScheduledTask: true,
Body: map[string]interface{}{"mapstring": "mapinterface"},
Body: map[string]any{"mapstring": "mapinterface"},
}},
},
{
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestSendCommand(t *testing.T) {
Trigger: "someTrigger",
SendUpdatesToClient: true,
UpdateScheduledTask: true,
Body: map[string]interface{}{"mapstring": "mapinterface"},
Body: map[string]any{"mapstring": "mapinterface"},
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion lidarr/downloadclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (l *Lidarr) TestDownloadClient(client *DownloadClientInput) error {

// TestDownloadClientContext tests a download client.
func (l *Lidarr) TestDownloadClientContext(ctx context.Context, client *DownloadClientInput) error {
var output interface{}
var output any

var body bytes.Buffer
if err := json.NewEncoder(&body).Encode(client); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions lidarr/downloadclientconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (l *Lidarr) GetDownloadClientConfig() (*DownloadClientConfig, error) {
return l.GetDownloadClientConfigContext(context.Background())
}

// GetDownloadClientConfig returns the download client config.
// GetDownloadClientConfigContext returns the download client config.
func (l *Lidarr) GetDownloadClientConfigContext(ctx context.Context) (*DownloadClientConfig, error) {
var output DownloadClientConfig

Expand All @@ -43,7 +43,7 @@ func (l *Lidarr) UpdateDownloadClientConfig(downloadClientConfig *DownloadClient
return l.UpdateDownloadClientConfigContext(context.Background(), downloadClientConfig)
}

// UpdateDownloadClientConfig update the single download client config.
// UpdateDownloadClientConfigContext update the single download client config.
func (l *Lidarr) UpdateDownloadClientConfigContext(ctx context.Context,
config *DownloadClientConfig,
) (*DownloadClientConfig, error) {
Expand Down
9 changes: 5 additions & 4 deletions lidarr/exclusions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"path"
"strings"

"golift.io/starr"
)
Expand Down Expand Up @@ -65,17 +66,17 @@ func (l *Lidarr) DeleteExclusions(ids []int64) error {

// DeleteExclusionsContext removes exclusions from Lidarr.
func (l *Lidarr) DeleteExclusionsContext(ctx context.Context, ids []int64) error {
var errs string
var errs strings.Builder

for _, id := range ids {
req := starr.Request{URI: path.Join(bpExclusions, starr.Str(id))}
if err := l.DeleteAny(ctx, req); err != nil {
errs += fmt.Sprintf("api.Post(%s): %v ", &req, err)
fmt.Fprintf(&errs, "api.Post(%s): %v ", &req, err)
}
}

if errs != "" {
return fmt.Errorf("%w: %s", starr.ErrRequestError, errs)
if errs.Len() > 0 {
return fmt.Errorf("%w: %s", starr.ErrRequestError, errs.String())
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion lidarr/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (l *Lidarr) FailContext(ctx context.Context, historyID int64) error {
return fmt.Errorf("%w: invalid history ID: %d", starr.ErrRequestError, historyID)
}

var output interface{}
var output any

req := starr.Request{
URI: path.Join(bpHistory, "failed"),
Expand Down
4 changes: 2 additions & 2 deletions lidarr/importlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (l *Lidarr) GetImportList(importListID int64) (*ImportListOutput, error) {
return l.GetImportListContext(context.Background(), importListID)
}

// GetIndGetImportListContextexer returns a single import list.
// GetImportListContext returns a single import list.
func (l *Lidarr) GetImportListContext(ctx context.Context, importListID int64) (*ImportListOutput, error) {
var output ImportListOutput

Expand Down Expand Up @@ -125,7 +125,7 @@ func (l *Lidarr) TestImportList(list *ImportListInput) error {

// TestImportListContextt tests an import list.
func (l *Lidarr) TestImportListContextt(ctx context.Context, list *ImportListInput) error {
var output interface{}
var output any

var body bytes.Buffer
if err := json.NewEncoder(&body).Encode(list); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion lidarr/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (l *Lidarr) TestIndexer(indexer *IndexerInput) error {

// TestIndexerContext tests an indexer.
func (l *Lidarr) TestIndexerContext(ctx context.Context, indexer *IndexerInput) error {
var output interface{}
var output any

var body bytes.Buffer
if err := json.NewEncoder(&body).Encode(indexer); err != nil {
Expand Down
1 change: 1 addition & 0 deletions lidarr/lidarr.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package lidarr is the SDK client for the Lidarr API.
package lidarr

import (
Expand Down
2 changes: 1 addition & 1 deletion lidarr/manualimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (l *Lidarr) ManualImportReprocess(manualimport *ManualImportInput) error {

// ManualImportReprocessContext reprocesses a manual import (POST).
func (l *Lidarr) ManualImportReprocessContext(ctx context.Context, manualimport *ManualImportInput) error {
var output interface{}
var output any

var body bytes.Buffer
if err := json.NewEncoder(&body).Encode(manualimport); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion lidarr/mediamanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (l *Lidarr) GetMediaManagement() (*MediaManagement, error) {
return l.GetMediaManagementContext(context.Background())
}

// GetMediaManagement returns the Media Management.
// GetMediaManagementContext returns the Media Management.
func (l *Lidarr) GetMediaManagementContext(ctx context.Context) (*MediaManagement, error) {
var output MediaManagement

Expand Down
1 change: 1 addition & 0 deletions lidarr/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func (l *Lidarr) DeleteNotification(notificationID int64) error {
return l.DeleteNotificationContext(context.Background(), notificationID)
}

// DeleteNotificationContext removes a single notification.
func (l *Lidarr) DeleteNotificationContext(ctx context.Context, notificationID int64) error {
req := starr.Request{URI: path.Join(bpNotification, starr.Str(notificationID))}
if err := l.DeleteAny(ctx, req); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion lidarr/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (l *Lidarr) QueueGrabContext(ctx context.Context, ids ...int64) error {
return fmt.Errorf("json.Marshal(%s): %w", bpQueue, err)
}

var output interface{} // any ok
var output any // any ok

req := starr.Request{URI: path.Join(bpQueue, "grab", "bulk"), Body: &body}
if err := l.PostInto(ctx, req, &output); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion lidarr/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (l *Lidarr) GetTracksByArtist(artistID int64) ([]*Track, error) {
return l.GetTracksByArtistContext(context.Background(), artistID)
}

// GetTracksByAlbumRelease gets track files using an artist ID.
// GetTracksByArtistContext gets track files using an artist ID.
func (l *Lidarr) GetTracksByArtistContext(ctx context.Context, artistID int64) ([]*Track, error) {
req := starr.Request{URI: bpTrack, Query: make(url.Values)}
req.Query.Add("artistId", starr.Str(artistID))
Expand Down
4 changes: 2 additions & 2 deletions paginate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ type PageReq struct {
type Sorting string

const (
// SortAsc is the default, and sorts lists in ascending order.
// SortAscend is the default, and sorts lists in ascending order.
SortAscend Sorting = "ascending"
// SortDesc flips the sort order to descending.
// SortDescend flips the sort order to descending.
SortDescend Sorting = "descending"
)

Expand Down
Loading
Loading