1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

refactor: replace interface{} with any

This commit is contained in:
Frédéric Guillot 2025-08-05 20:21:28 -07:00
parent 045f2f1747
commit 80f48c88c7
12 changed files with 26 additions and 26 deletions

View file

@ -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)

View file

@ -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
}

View file

@ -701,7 +701,7 @@ func (o *options) SortedOptions(redactSecret bool) []*option {
mediaProxyPrivateKeyValue = "<binary-data>"
}
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,

View file

@ -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,

View file

@ -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")

View file

@ -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")

View file

@ -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,

View file

@ -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"},
}
}

View file

@ -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)"},
}
}

View file

@ -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

View file

@ -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,

View file

@ -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 {