diff --git a/client/request.go b/client/request.go index 43fe668d..5af7f86b 100644 --- a/client/request.go +++ b/client/request.go @@ -45,7 +45,7 @@ func (r *request) Get(path string) (io.ReadCloser, error) { return r.execute(http.MethodGet, path, nil) } -func (r *request) Post(path string, data interface{}) (io.ReadCloser, error) { +func (r *request) Post(path string, data any) (io.ReadCloser, error) { return r.execute(http.MethodPost, path, data) } @@ -53,7 +53,7 @@ func (r *request) PostFile(path string, f io.ReadCloser) (io.ReadCloser, error) return r.execute(http.MethodPost, path, f) } -func (r *request) Put(path string, data interface{}) (io.ReadCloser, error) { +func (r *request) Put(path string, data any) (io.ReadCloser, error) { return r.execute(http.MethodPut, path, data) } @@ -62,7 +62,7 @@ func (r *request) Delete(path string) error { return err } -func (r *request) execute(method, path string, data interface{}) (io.ReadCloser, error) { +func (r *request) execute(method, path string, data any) (io.ReadCloser, error) { if r.endpoint == "" { return nil, ErrEmptyEndpoint } @@ -160,7 +160,7 @@ func (r *request) buildHeaders() http.Header { return headers } -func (r *request) toJSON(v interface{}) []byte { +func (r *request) toJSON(v any) []byte { b, err := json.Marshal(v) if err != nil { log.Println("Unable to convert interface to JSON:", err) diff --git a/internal/api/entry.go b/internal/api/entry.go index d1c2976e..937a517a 100644 --- a/internal/api/entry.go +++ b/internal/api/entry.go @@ -338,7 +338,7 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) { return } - json.OK(w, r, map[string]interface{}{"content": mediaproxy.RewriteDocumentWithRelativeProxyURL(h.router, entry.Content), "reading_time": entry.ReadingTime}) + json.OK(w, r, map[string]any{"content": mediaproxy.RewriteDocumentWithRelativeProxyURL(h.router, entry.Content), "reading_time": entry.ReadingTime}) return } diff --git a/internal/config/options.go b/internal/config/options.go index a01c8170..ba626b6e 100644 --- a/internal/config/options.go +++ b/internal/config/options.go @@ -701,7 +701,7 @@ func (o *options) SortedOptions(redactSecret bool) []*option { mediaProxyPrivateKeyValue = "" } - var keyValues = map[string]interface{}{ + var keyValues = map[string]any{ "ADMIN_PASSWORD": redactSecretValue(o.adminPassword, redactSecret), "ADMIN_USERNAME": o.adminUsername, "AUTH_PROXY_HEADER": o.authProxyHeader, diff --git a/internal/integration/omnivore/omnivore.go b/internal/integration/omnivore/omnivore.go index b182a10a..92a27c1d 100644 --- a/internal/integration/omnivore/omnivore.go +++ b/internal/integration/omnivore/omnivore.go @@ -74,10 +74,10 @@ func NewClient(apiToken string, apiEndpoint string) Client { } func (c *client) SaveUrl(url string) error { - var payload = map[string]interface{}{ + var payload = map[string]any{ "query": mutation, - "variables": map[string]interface{}{ - "input": map[string]interface{}{ + "variables": map[string]any{ + "input": map[string]any{ "clientRequestId": crypto.GenerateUUID(), "source": "api", "url": url, diff --git a/internal/model/app_session.go b/internal/model/app_session.go index 884d39d6..afd18d32 100644 --- a/internal/model/app_session.go +++ b/internal/model/app_session.go @@ -44,7 +44,7 @@ func (s *SessionData) Value() (driver.Value, error) { } // Scan converts raw JSON data. -func (s *SessionData) Scan(src interface{}) error { +func (s *SessionData) Scan(src any) error { source, ok := src.([]byte) if !ok { return errors.New("session: unable to assert type of src") diff --git a/internal/model/webauthn.go b/internal/model/webauthn.go index fb758927..8bda49f5 100644 --- a/internal/model/webauthn.go +++ b/internal/model/webauthn.go @@ -23,7 +23,7 @@ func (s WebAuthnSession) Value() (driver.Value, error) { return json.Marshal(s) } -func (s *WebAuthnSession) Scan(value interface{}) error { +func (s *WebAuthnSession) Scan(value any) error { b, ok := value.([]byte) if !ok { return errors.New("type assertion to []byte failed") diff --git a/internal/storage/entry_pagination_builder.go b/internal/storage/entry_pagination_builder.go index 6a7c5e8e..cc56c6b2 100644 --- a/internal/storage/entry_pagination_builder.go +++ b/internal/storage/entry_pagination_builder.go @@ -15,7 +15,7 @@ import ( type EntryPaginationBuilder struct { store *Storage conditions []string - args []interface{} + args []any entryID int64 order string direction string @@ -170,7 +170,7 @@ func (e *EntryPaginationBuilder) getEntry(tx *sql.Tx, entryID int64) (*model.Ent func NewEntryPaginationBuilder(store *Storage, userID, entryID int64, order, direction string) *EntryPaginationBuilder { return &EntryPaginationBuilder{ store: store, - args: []interface{}{userID, "removed"}, + args: []any{userID, "removed"}, conditions: []string{"e.user_id = $1", "e.status <> $2"}, entryID: entryID, order: order, diff --git a/internal/storage/entry_query_builder.go b/internal/storage/entry_query_builder.go index 3403c388..9e411c92 100644 --- a/internal/storage/entry_query_builder.go +++ b/internal/storage/entry_query_builder.go @@ -18,7 +18,7 @@ import ( // EntryQueryBuilder builds a SQL query to fetch entries. type EntryQueryBuilder struct { store *Storage - args []interface{} + args []any conditions []string sortExpressions []string limit int @@ -468,7 +468,7 @@ func (e *EntryQueryBuilder) buildSorting() string { func NewEntryQueryBuilder(store *Storage, userID int64) *EntryQueryBuilder { return &EntryQueryBuilder{ store: store, - args: []interface{}{userID}, + args: []any{userID}, conditions: []string{"e.user_id = $1"}, } } diff --git a/internal/storage/feed_query_builder.go b/internal/storage/feed_query_builder.go index 608b748c..c30ccd7c 100644 --- a/internal/storage/feed_query_builder.go +++ b/internal/storage/feed_query_builder.go @@ -16,14 +16,14 @@ import ( // FeedQueryBuilder builds a SQL query to fetch feeds. type FeedQueryBuilder struct { store *Storage - args []interface{} + args []any conditions []string sortExpressions []string limit int offset int withCounters bool counterJoinFeeds bool - counterArgs []interface{} + counterArgs []any counterConditions []string } @@ -31,9 +31,9 @@ type FeedQueryBuilder struct { func NewFeedQueryBuilder(store *Storage, userID int64) *FeedQueryBuilder { return &FeedQueryBuilder{ store: store, - args: []interface{}{userID}, + args: []any{userID}, conditions: []string{"f.user_id = $1"}, - counterArgs: []interface{}{userID, model.EntryStatusRead, model.EntryStatusUnread}, + counterArgs: []any{userID, model.EntryStatusRead, model.EntryStatusUnread}, counterConditions: []string{"e.user_id = $1", "e.status IN ($2, $3)"}, } } diff --git a/internal/storage/session.go b/internal/storage/session.go index 38270d6c..666a0504 100644 --- a/internal/storage/session.go +++ b/internal/storage/session.go @@ -70,7 +70,7 @@ func (s *Storage) UpdateAppSessionField(sessionID, field string, value any) erro return nil } -func (s *Storage) UpdateAppSessionObjectField(sessionID, field string, value interface{}) error { +func (s *Storage) UpdateAppSessionObjectField(sessionID, field string, value any) error { query := ` UPDATE sessions diff --git a/internal/storage/user.go b/internal/storage/user.go index 6ca83515..22cd1a77 100644 --- a/internal/storage/user.go +++ b/internal/storage/user.go @@ -521,7 +521,7 @@ func (s *Storage) UserByAPIKey(token string) (*model.User, error) { return s.fetchUser(query, token) } -func (s *Storage) fetchUser(query string, args ...interface{}) (*model.User, error) { +func (s *Storage) fetchUser(query string, args ...any) (*model.User, error) { var user model.User err := s.db.QueryRow(query, args...).Scan( &user.ID, diff --git a/internal/template/functions.go b/internal/template/functions.go index fe06f247..77c2a7cb 100644 --- a/internal/template/functions.go +++ b/internal/template/functions.go @@ -46,7 +46,7 @@ func (f *funcMap) Map() template.FuncMap { "hasAuthProxy": func() bool { return config.Opts.AuthProxyHeader() != "" }, - "route": func(name string, args ...interface{}) string { + "route": func(name string, args ...any) string { return route.Path(f.router, name, args...) }, "safeURL": func(url string) template.URL { @@ -105,20 +105,20 @@ func (f *funcMap) Map() template.FuncMap { "elapsed": func(timezone string, t time.Time) string { return "" }, - "t": func(key interface{}, args ...interface{}) string { + "t": func(key any, args ...any) string { return "" }, - "plural": func(key string, n int, args ...interface{}) string { + "plural": func(key string, n int, args ...any) string { return "" }, } } -func dict(values ...interface{}) (map[string]interface{}, error) { +func dict(values ...any) (map[string]any, error) { if len(values)%2 != 0 { return nil, fmt.Errorf("dict expects an even number of arguments") } - dict := make(map[string]interface{}, len(values)/2) + dict := make(map[string]any, len(values)/2) for i := 0; i < len(values); i += 2 { key, ok := values[i].(string) if !ok {