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:
parent
045f2f1747
commit
80f48c88c7
12 changed files with 26 additions and 26 deletions
|
@ -45,7 +45,7 @@ func (r *request) Get(path string) (io.ReadCloser, error) {
|
||||||
return r.execute(http.MethodGet, path, nil)
|
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)
|
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)
|
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)
|
return r.execute(http.MethodPut, path, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ func (r *request) Delete(path string) error {
|
||||||
return err
|
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 == "" {
|
if r.endpoint == "" {
|
||||||
return nil, ErrEmptyEndpoint
|
return nil, ErrEmptyEndpoint
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ func (r *request) buildHeaders() http.Header {
|
||||||
return headers
|
return headers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *request) toJSON(v interface{}) []byte {
|
func (r *request) toJSON(v any) []byte {
|
||||||
b, err := json.Marshal(v)
|
b, err := json.Marshal(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Unable to convert interface to JSON:", err)
|
log.Println("Unable to convert interface to JSON:", err)
|
||||||
|
|
|
@ -338,7 +338,7 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,7 +701,7 @@ func (o *options) SortedOptions(redactSecret bool) []*option {
|
||||||
mediaProxyPrivateKeyValue = "<binary-data>"
|
mediaProxyPrivateKeyValue = "<binary-data>"
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyValues = map[string]interface{}{
|
var keyValues = map[string]any{
|
||||||
"ADMIN_PASSWORD": redactSecretValue(o.adminPassword, redactSecret),
|
"ADMIN_PASSWORD": redactSecretValue(o.adminPassword, redactSecret),
|
||||||
"ADMIN_USERNAME": o.adminUsername,
|
"ADMIN_USERNAME": o.adminUsername,
|
||||||
"AUTH_PROXY_HEADER": o.authProxyHeader,
|
"AUTH_PROXY_HEADER": o.authProxyHeader,
|
||||||
|
|
|
@ -74,10 +74,10 @@ func NewClient(apiToken string, apiEndpoint string) Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) SaveUrl(url string) error {
|
func (c *client) SaveUrl(url string) error {
|
||||||
var payload = map[string]interface{}{
|
var payload = map[string]any{
|
||||||
"query": mutation,
|
"query": mutation,
|
||||||
"variables": map[string]interface{}{
|
"variables": map[string]any{
|
||||||
"input": map[string]interface{}{
|
"input": map[string]any{
|
||||||
"clientRequestId": crypto.GenerateUUID(),
|
"clientRequestId": crypto.GenerateUUID(),
|
||||||
"source": "api",
|
"source": "api",
|
||||||
"url": url,
|
"url": url,
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (s *SessionData) Value() (driver.Value, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan converts raw JSON data.
|
// Scan converts raw JSON data.
|
||||||
func (s *SessionData) Scan(src interface{}) error {
|
func (s *SessionData) Scan(src any) error {
|
||||||
source, ok := src.([]byte)
|
source, ok := src.([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("session: unable to assert type of src")
|
return errors.New("session: unable to assert type of src")
|
||||||
|
|
|
@ -23,7 +23,7 @@ func (s WebAuthnSession) Value() (driver.Value, error) {
|
||||||
return json.Marshal(s)
|
return json.Marshal(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *WebAuthnSession) Scan(value interface{}) error {
|
func (s *WebAuthnSession) Scan(value any) error {
|
||||||
b, ok := value.([]byte)
|
b, ok := value.([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("type assertion to []byte failed")
|
return errors.New("type assertion to []byte failed")
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
type EntryPaginationBuilder struct {
|
type EntryPaginationBuilder struct {
|
||||||
store *Storage
|
store *Storage
|
||||||
conditions []string
|
conditions []string
|
||||||
args []interface{}
|
args []any
|
||||||
entryID int64
|
entryID int64
|
||||||
order string
|
order string
|
||||||
direction 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 {
|
func NewEntryPaginationBuilder(store *Storage, userID, entryID int64, order, direction string) *EntryPaginationBuilder {
|
||||||
return &EntryPaginationBuilder{
|
return &EntryPaginationBuilder{
|
||||||
store: store,
|
store: store,
|
||||||
args: []interface{}{userID, "removed"},
|
args: []any{userID, "removed"},
|
||||||
conditions: []string{"e.user_id = $1", "e.status <> $2"},
|
conditions: []string{"e.user_id = $1", "e.status <> $2"},
|
||||||
entryID: entryID,
|
entryID: entryID,
|
||||||
order: order,
|
order: order,
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
// EntryQueryBuilder builds a SQL query to fetch entries.
|
// EntryQueryBuilder builds a SQL query to fetch entries.
|
||||||
type EntryQueryBuilder struct {
|
type EntryQueryBuilder struct {
|
||||||
store *Storage
|
store *Storage
|
||||||
args []interface{}
|
args []any
|
||||||
conditions []string
|
conditions []string
|
||||||
sortExpressions []string
|
sortExpressions []string
|
||||||
limit int
|
limit int
|
||||||
|
@ -468,7 +468,7 @@ func (e *EntryQueryBuilder) buildSorting() string {
|
||||||
func NewEntryQueryBuilder(store *Storage, userID int64) *EntryQueryBuilder {
|
func NewEntryQueryBuilder(store *Storage, userID int64) *EntryQueryBuilder {
|
||||||
return &EntryQueryBuilder{
|
return &EntryQueryBuilder{
|
||||||
store: store,
|
store: store,
|
||||||
args: []interface{}{userID},
|
args: []any{userID},
|
||||||
conditions: []string{"e.user_id = $1"},
|
conditions: []string{"e.user_id = $1"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@ import (
|
||||||
// FeedQueryBuilder builds a SQL query to fetch feeds.
|
// FeedQueryBuilder builds a SQL query to fetch feeds.
|
||||||
type FeedQueryBuilder struct {
|
type FeedQueryBuilder struct {
|
||||||
store *Storage
|
store *Storage
|
||||||
args []interface{}
|
args []any
|
||||||
conditions []string
|
conditions []string
|
||||||
sortExpressions []string
|
sortExpressions []string
|
||||||
limit int
|
limit int
|
||||||
offset int
|
offset int
|
||||||
withCounters bool
|
withCounters bool
|
||||||
counterJoinFeeds bool
|
counterJoinFeeds bool
|
||||||
counterArgs []interface{}
|
counterArgs []any
|
||||||
counterConditions []string
|
counterConditions []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ type FeedQueryBuilder struct {
|
||||||
func NewFeedQueryBuilder(store *Storage, userID int64) *FeedQueryBuilder {
|
func NewFeedQueryBuilder(store *Storage, userID int64) *FeedQueryBuilder {
|
||||||
return &FeedQueryBuilder{
|
return &FeedQueryBuilder{
|
||||||
store: store,
|
store: store,
|
||||||
args: []interface{}{userID},
|
args: []any{userID},
|
||||||
conditions: []string{"f.user_id = $1"},
|
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)"},
|
counterConditions: []string{"e.user_id = $1", "e.status IN ($2, $3)"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (s *Storage) UpdateAppSessionField(sessionID, field string, value any) erro
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Storage) UpdateAppSessionObjectField(sessionID, field string, value interface{}) error {
|
func (s *Storage) UpdateAppSessionObjectField(sessionID, field string, value any) error {
|
||||||
query := `
|
query := `
|
||||||
UPDATE
|
UPDATE
|
||||||
sessions
|
sessions
|
||||||
|
|
|
@ -521,7 +521,7 @@ func (s *Storage) UserByAPIKey(token string) (*model.User, error) {
|
||||||
return s.fetchUser(query, token)
|
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
|
var user model.User
|
||||||
err := s.db.QueryRow(query, args...).Scan(
|
err := s.db.QueryRow(query, args...).Scan(
|
||||||
&user.ID,
|
&user.ID,
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (f *funcMap) Map() template.FuncMap {
|
||||||
"hasAuthProxy": func() bool {
|
"hasAuthProxy": func() bool {
|
||||||
return config.Opts.AuthProxyHeader() != ""
|
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...)
|
return route.Path(f.router, name, args...)
|
||||||
},
|
},
|
||||||
"safeURL": func(url string) template.URL {
|
"safeURL": func(url string) template.URL {
|
||||||
|
@ -105,20 +105,20 @@ func (f *funcMap) Map() template.FuncMap {
|
||||||
"elapsed": func(timezone string, t time.Time) string {
|
"elapsed": func(timezone string, t time.Time) string {
|
||||||
return ""
|
return ""
|
||||||
},
|
},
|
||||||
"t": func(key interface{}, args ...interface{}) string {
|
"t": func(key any, args ...any) string {
|
||||||
return ""
|
return ""
|
||||||
},
|
},
|
||||||
"plural": func(key string, n int, args ...interface{}) string {
|
"plural": func(key string, n int, args ...any) string {
|
||||||
return ""
|
return ""
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dict(values ...interface{}) (map[string]interface{}, error) {
|
func dict(values ...any) (map[string]any, error) {
|
||||||
if len(values)%2 != 0 {
|
if len(values)%2 != 0 {
|
||||||
return nil, fmt.Errorf("dict expects an even number of arguments")
|
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 {
|
for i := 0; i < len(values); i += 2 {
|
||||||
key, ok := values[i].(string)
|
key, ok := values[i].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue