Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: golangci-lint version (#1381)
boojackff8851fd9f7a
diff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.ymlindex ce87f1867..186352b43 100644--- a/.github/workflows/backend-tests.yml+++ b/.github/workflows/backend-tests.yml@@ -23,7 +23,8 @@ jobs:- name: golangci-lintuses: golangci/golangci-lint-action@v3with:- args: -v+ version: v1.52.0+ args: -v --timeout=3mskip-cache: truego-tests:diff --git a/plugin/openai/chat_completion.go b/plugin/openai/chat_completion.goindex 9e72d6811..d9b94e297 100644--- a/plugin/openai/chat_completion.go+++ b/plugin/openai/chat_completion.go@@ -19,7 +19,7 @@ type ChatCompletionChoice struct {}type ChatCompletionResponse struct {- Error interface{} `json:"error"`+ Error any `json:"error"`Model string `json:"model"`Choices []ChatCompletionChoice `json:"choices"`}@@ -33,7 +33,7 @@ func PostChatCompletion(messages []ChatCompletionMessage, apiKey string, apiHostreturn "", err}- values := map[string]interface{}{+ values := map[string]any{"model": "gpt-3.5-turbo","messages": messages,"max_tokens": 2000,diff --git a/plugin/openai/text_completion.go b/plugin/openai/text_completion.goindex be7846ae5..4e1d33219 100644--- a/plugin/openai/text_completion.go+++ b/plugin/openai/text_completion.go@@ -14,7 +14,7 @@ type TextCompletionChoice struct {}type TextCompletionResponse struct {- Error interface{} `json:"error"`+ Error any `json:"error"`Model string `json:"model"`Choices []TextCompletionChoice `json:"choices"`}@@ -28,7 +28,7 @@ func PostTextCompletion(prompt string, apiKey string, apiHost string) (string, ereturn "", err}- values := map[string]interface{}{+ values := map[string]any{"model": "gpt-3.5-turbo","prompt": prompt,"temperature": 0.5,diff --git a/plugin/storage/s3/s3.go b/plugin/storage/s3/s3.goindex 5ab103fed..878012248 100644--- a/plugin/storage/s3/s3.go+++ b/plugin/storage/s3/s3.go@@ -28,7 +28,7 @@ type Client struct {}func NewClient(ctx context.Context, config *Config) (*Client, error) {- resolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {+ resolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...any) (aws.Endpoint, error) {return aws.Endpoint{URL: config.EndPoint,SigningRegion: config.Region,diff --git a/server/common.go b/server/common.goindex 4aabe5de0..6a15ffa50 100644--- a/server/common.go+++ b/server/common.go@@ -9,10 +9,10 @@ import ()type response struct {- Data interface{} `json:"data"`+ Data any `json:"data"`}-func composeResponse(data interface{}) response {+func composeResponse(data any) response {return response{Data: data,}diff --git a/server/rss.go b/server/rss.goindex e77602ee6..88d4dc4d7 100644--- a/server/rss.go+++ b/server/rss.go@@ -135,14 +135,14 @@ func getSystemCustomizedProfile(ctx context.Context, s *Server) (api.CustomizedPcontinue}- var value interface{}+ var value anyerr := json.Unmarshal([]byte(systemSetting.Value), &value)if err != nil {return api.CustomizedProfile{}, err}if systemSetting.Name == api.SystemSettingCustomizedProfileName {- valueMap := value.(map[string]interface{})+ valueMap := value.(map[string]any)systemStatus.CustomizedProfile = api.CustomizedProfile{}if v := valueMap["name"]; v != nil {systemStatus.CustomizedProfile.Name = v.(string)diff --git a/server/system.go b/server/system.goindex 0574ee6f4..d1fc53abb 100644--- a/server/system.go+++ b/server/system.go@@ -63,7 +63,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {continue}- var baseValue interface{}+ var baseValue anyerr := json.Unmarshal([]byte(systemSetting.Value), &baseValue)if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting value").SetInternal(err)diff --git a/store/db/migration_history.go b/store/db/migration_history.goindex 5906e5243..472bfb53e 100644--- a/store/db/migration_history.go+++ b/store/db/migration_history.go@@ -54,7 +54,7 @@ func (db *DB) UpsertMigrationHistory(ctx context.Context, upsert *MigrationHisto}func findMigrationHistoryList(ctx context.Context, tx *sql.Tx, find *MigrationHistoryFind) ([]*MigrationHistory, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if v := find.Version; v != nil {where, args = append(where, "version = ?"), append(args, *v)diff --git a/store/idp.go b/store/idp.goindex 9958757bc..c444b8fb4 100644--- a/store/idp.go+++ b/store/idp.go@@ -157,7 +157,7 @@ func (s *Store) UpdateIdentityProvider(ctx context.Context, update *UpdateIdenti}defer tx.Rollback()- set, args := []string{}, []interface{}{}+ set, args := []string{}, []any{}if v := update.Name; v != nil {set, args = append(set, "name = ?"), append(args, *v)}@@ -220,7 +220,7 @@ func (s *Store) DeleteIdentityProvider(ctx context.Context, delete *DeleteIdenti}defer tx.Rollback()- where, args := []string{"id = ?"}, []interface{}{delete.ID}+ where, args := []string{"id = ?"}, []any{delete.ID}stmt := `DELETE FROM idp WHERE ` + strings.Join(where, " AND ")result, err := tx.ExecContext(ctx, stmt, args...)if err != nil {@@ -242,7 +242,7 @@ func (s *Store) DeleteIdentityProvider(ctx context.Context, delete *DeleteIdenti}func listIdentityProviders(ctx context.Context, tx *sql.Tx, find *FindIdentityProviderMessage) ([]*IdentityProviderMessage, error) {- where, args := []string{"TRUE"}, []interface{}{}+ where, args := []string{"TRUE"}, []any{}if v := find.ID; v != nil {where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)}@@ -289,8 +289,10 @@ func listIdentityProviders(ctx context.Context, tx *sql.Tx, find *FindIdentityPr}identityProviderMessages = append(identityProviderMessages, &identityProviderMessage)}+if err := rows.Err(); err != nil {return nil, FormatError(err)}+return identityProviderMessages, nil}diff --git a/store/memo.go b/store/memo.goindex f1eba20dc..448cecde4 100644--- a/store/memo.go+++ b/store/memo.go@@ -193,7 +193,7 @@ func (s *Store) DeleteMemo(ctx context.Context, delete *api.MemoDelete) error {func createMemoRaw(ctx context.Context, tx *sql.Tx, create *api.MemoCreate) (*memoRaw, error) {set := []string{"creator_id", "content", "visibility"}- args := []interface{}{create.CreatorID, create.Content, create.Visibility}+ args := []any{create.CreatorID, create.Content, create.Visibility}placeholder := []string{"?", "?", "?"}if v := create.CreatedTs; v != nil {@@ -224,7 +224,7 @@ func createMemoRaw(ctx context.Context, tx *sql.Tx, create *api.MemoCreate) (*me}func patchMemoRaw(ctx context.Context, tx *sql.Tx, patch *api.MemoPatch) (*memoRaw, error) {- set, args := []string{}, []interface{}{}+ set, args := []string{}, []any{}if v := patch.CreatedTs; v != nil {set, args = append(set, "created_ts = ?"), append(args, *v)@@ -267,7 +267,7 @@ func patchMemoRaw(ctx context.Context, tx *sql.Tx, patch *api.MemoPatch) (*memoR}func findMemoRawList(ctx context.Context, tx *sql.Tx, find *api.MemoFind) ([]*memoRaw, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if v := find.ID; v != nil {where, args = append(where, "memo.id = ?"), append(args, *v)@@ -352,7 +352,7 @@ func findMemoRawList(ctx context.Context, tx *sql.Tx, find *api.MemoFind) ([]*me}func deleteMemo(ctx context.Context, tx *sql.Tx, delete *api.MemoDelete) error {- where, args := []string{"id = ?"}, []interface{}{delete.ID}+ where, args := []string{"id = ?"}, []any{delete.ID}stmt := `DELETE FROM memo WHERE ` + strings.Join(where, " AND ")result, err := tx.ExecContext(ctx, stmt, args...)diff --git a/store/memo_organizer.go b/store/memo_organizer.goindex 104dd2b73..844ba27e5 100644--- a/store/memo_organizer.go+++ b/store/memo_organizer.go@@ -148,7 +148,7 @@ func upsertMemoOrganizer(ctx context.Context, tx *sql.Tx, upsert *api.MemoOrgani}func deleteMemoOrganizer(ctx context.Context, tx *sql.Tx, delete *api.MemoOrganizerDelete) error {- where, args := []string{}, []interface{}{}+ where, args := []string{}, []any{}if v := delete.MemoID; v != nil {where, args = append(where, "memo_id = ?"), append(args, *v)diff --git a/store/memo_resource.go b/store/memo_resource.goindex 5491ddc66..92fe37de2 100644--- a/store/memo_resource.go+++ b/store/memo_resource.go@@ -108,7 +108,7 @@ func (s *Store) DeleteMemoResource(ctx context.Context, delete *api.MemoResource}func findMemoResourceList(ctx context.Context, tx *sql.Tx, find *api.MemoResourceFind) ([]*memoResourceRaw, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if v := find.MemoID; v != nil {where, args = append(where, "memo_id = ?"), append(args, *v)@@ -157,7 +157,7 @@ func findMemoResourceList(ctx context.Context, tx *sql.Tx, find *api.MemoResourcfunc upsertMemoResource(ctx context.Context, tx *sql.Tx, upsert *api.MemoResourceUpsert) (*memoResourceRaw, error) {set := []string{"memo_id", "resource_id"}- args := []interface{}{upsert.MemoID, upsert.ResourceID}+ args := []any{upsert.MemoID, upsert.ResourceID}placeholder := []string{"?", "?"}if v := upsert.UpdatedTs; v != nil {@@ -188,7 +188,7 @@ func upsertMemoResource(ctx context.Context, tx *sql.Tx, upsert *api.MemoResourc}func deleteMemoResource(ctx context.Context, tx *sql.Tx, delete *api.MemoResourceDelete) error {- where, args := []string{}, []interface{}{}+ where, args := []string{}, []any{}if v := delete.MemoID; v != nil {where, args = append(where, "memo_id = ?"), append(args, *v)diff --git a/store/resource.go b/store/resource.goindex 351c11b2b..57f33a494 100644--- a/store/resource.go+++ b/store/resource.go@@ -192,7 +192,7 @@ func (s *Store) PatchResource(ctx context.Context, patch *api.ResourcePatch) (*afunc (s *Store) createResourceImpl(ctx context.Context, tx *sql.Tx, create *api.ResourceCreate) (*resourceRaw, error) {fields := []string{"filename", "blob", "external_link", "type", "size", "creator_id"}- values := []interface{}{create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID}+ values := []any{create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID}placeholders := []string{"?", "?", "?", "?", "?", "?"}if s.profile.IsDev() {fields = append(fields, "visibility")@@ -208,7 +208,7 @@ func (s *Store) createResourceImpl(ctx context.Context, tx *sql.Tx, create *api.RETURNING id, ` + strings.Join(fields, ",") + `, created_ts, updated_ts`var resourceRaw resourceRaw- dests := []interface{}{+ dests := []any{&resourceRaw.ID,&resourceRaw.Filename,&resourceRaw.Blob,@@ -220,7 +220,7 @@ func (s *Store) createResourceImpl(ctx context.Context, tx *sql.Tx, create *api.if s.profile.IsDev() {dests = append(dests, &resourceRaw.Visibility)}- dests = append(dests, []interface{}{&resourceRaw.CreatedTs, &resourceRaw.UpdatedTs}...)+ dests = append(dests, []any{&resourceRaw.CreatedTs, &resourceRaw.UpdatedTs}...)if err := tx.QueryRowContext(ctx, query, values...).Scan(dests...); err != nil {return nil, FormatError(err)}@@ -229,7 +229,7 @@ func (s *Store) createResourceImpl(ctx context.Context, tx *sql.Tx, create *api.}func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.ResourcePatch) (*resourceRaw, error) {- set, args := []string{}, []interface{}{}+ set, args := []string{}, []any{}if v := patch.UpdatedTs; v != nil {set, args = append(set, "updated_ts = ?"), append(args, *v)@@ -256,7 +256,7 @@ func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.ReWHERE id = ?RETURNING ` + strings.Join(fields, ", ")var resourceRaw resourceRaw- dests := []interface{}{+ dests := []any{&resourceRaw.ID,&resourceRaw.Filename,&resourceRaw.ExternalLink,@@ -277,7 +277,7 @@ func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.Re}func (s *Store) findResourceListImpl(ctx context.Context, tx *sql.Tx, find *api.ResourceFind) ([]*resourceRaw, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if v := find.ID; v != nil {where, args = append(where, "resource.id = ?"), append(args, *v)@@ -319,7 +319,7 @@ func (s *Store) findResourceListImpl(ctx context.Context, tx *sql.Tx, find *api.resourceRawList := make([]*resourceRaw, 0)for rows.Next() {var resourceRaw resourceRaw- dests := []interface{}{+ dests := []any{&resourceRaw.LinkedMemoAmount,&resourceRaw.ID,&resourceRaw.Filename,@@ -350,7 +350,7 @@ func (s *Store) findResourceListImpl(ctx context.Context, tx *sql.Tx, find *api.}func deleteResource(ctx context.Context, tx *sql.Tx, delete *api.ResourceDelete) error {- where, args := []string{"id = ?"}, []interface{}{delete.ID}+ where, args := []string{"id = ?"}, []any{delete.ID}stmt := `DELETE FROM resource WHERE ` + strings.Join(where, " AND ")result, err := tx.ExecContext(ctx, stmt, args...)diff --git a/store/shortcut.go b/store/shortcut.goindex 5348097fe..d6b812799 100644--- a/store/shortcut.go+++ b/store/shortcut.go@@ -180,7 +180,7 @@ func createShortcut(ctx context.Context, tx *sql.Tx, create *api.ShortcutCreate)}func patchShortcut(ctx context.Context, tx *sql.Tx, patch *api.ShortcutPatch) (*shortcutRaw, error) {- set, args := []string{}, []interface{}{}+ set, args := []string{}, []any{}if v := patch.UpdatedTs; v != nil {set, args = append(set, "updated_ts = ?"), append(args, *v)@@ -220,7 +220,7 @@ func patchShortcut(ctx context.Context, tx *sql.Tx, patch *api.ShortcutPatch) (*}func findShortcutList(ctx context.Context, tx *sql.Tx, find *api.ShortcutFind) ([]*shortcutRaw, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if v := find.ID; v != nil {where, args = append(where, "id = ?"), append(args, *v)@@ -277,7 +277,7 @@ func findShortcutList(ctx context.Context, tx *sql.Tx, find *api.ShortcutFind) (}func deleteShortcut(ctx context.Context, tx *sql.Tx, delete *api.ShortcutDelete) error {- where, args := []string{}, []interface{}{}+ where, args := []string{}, []any{}if v := delete.ID; v != nil {where, args = append(where, "id = ?"), append(args, *v)diff --git a/store/storage.go b/store/storage.goindex 9bc777b48..0b560aec2 100644--- a/store/storage.go+++ b/store/storage.go@@ -125,7 +125,7 @@ func (s *Store) DeleteStorage(ctx context.Context, delete *api.StorageDelete) erfunc createStorageRaw(ctx context.Context, tx *sql.Tx, create *api.StorageCreate) (*storageRaw, error) {set := []string{"name", "type", "config"}- args := []interface{}{create.Name, create.Type}+ args := []any{create.Name, create.Type}placeholder := []string{"?", "?", "?"}var configBytes []byte@@ -162,7 +162,7 @@ func createStorageRaw(ctx context.Context, tx *sql.Tx, create *api.StorageCreate}func patchStorageRaw(ctx context.Context, tx *sql.Tx, patch *api.StoragePatch) (*storageRaw, error) {- set, args := []string{}, []interface{}{}+ set, args := []string{}, []any{}if v := patch.Name; v != nil {set, args = append(set, "name = ?"), append(args, *v)}@@ -213,7 +213,7 @@ func patchStorageRaw(ctx context.Context, tx *sql.Tx, patch *api.StoragePatch) (}func findStorageRawList(ctx context.Context, tx *sql.Tx, find *api.StorageFind) ([]*storageRaw, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if v := find.ID; v != nil {where, args = append(where, "id = ?"), append(args, *v)@@ -269,7 +269,7 @@ func findStorageRawList(ctx context.Context, tx *sql.Tx, find *api.StorageFind)}func deleteStorage(ctx context.Context, tx *sql.Tx, delete *api.StorageDelete) error {- where, args := []string{"id = ?"}, []interface{}{delete.ID}+ where, args := []string{"id = ?"}, []any{delete.ID}stmt := `DELETE FROM storage WHERE ` + strings.Join(where, " AND ")result, err := tx.ExecContext(ctx, stmt, args...)diff --git a/store/system_setting.go b/store/system_setting.goindex e77921636..f3fced795 100644--- a/store/system_setting.go+++ b/store/system_setting.go@@ -113,7 +113,7 @@ func upsertSystemSetting(ctx context.Context, tx *sql.Tx, upsert *api.SystemSett}func findSystemSettingList(ctx context.Context, tx *sql.Tx, find *api.SystemSettingFind) ([]*systemSettingRaw, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if find.Name.String() != "" {where, args = append(where, "name = ?"), append(args, find.Name.String())}diff --git a/store/tag.go b/store/tag.goindex ff40f61e4..0144a9d4b 100644--- a/store/tag.go+++ b/store/tag.go@@ -104,7 +104,7 @@ func upsertTag(ctx context.Context, tx *sql.Tx, upsert *api.TagUpsert) (*tagRaw,}func findTagList(ctx context.Context, tx *sql.Tx, find *api.TagFind) ([]*tagRaw, error) {- where, args := []string{"creator_id = ?"}, []interface{}{find.CreatorID}+ where, args := []string{"creator_id = ?"}, []any{find.CreatorID}query := `SELECT@@ -141,7 +141,7 @@ func findTagList(ctx context.Context, tx *sql.Tx, find *api.TagFind) ([]*tagRaw,}func deleteTag(ctx context.Context, tx *sql.Tx, delete *api.TagDelete) error {- where, args := []string{"name = ?", "creator_id = ?"}, []interface{}{delete.Name, delete.CreatorID}+ where, args := []string{"name = ?", "creator_id = ?"}, []any{delete.Name, delete.CreatorID}stmt := `DELETE FROM tag WHERE ` + strings.Join(where, " AND ")result, err := tx.ExecContext(ctx, stmt, args...)diff --git a/store/user.go b/store/user.goindex 6758aa0a7..a7e5ba222 100644--- a/store/user.go+++ b/store/user.go@@ -216,7 +216,7 @@ func createUser(ctx context.Context, tx *sql.Tx, create *api.UserCreate) (*userR}func patchUser(ctx context.Context, tx *sql.Tx, patch *api.UserPatch) (*userRaw, error) {- set, args := []string{}, []interface{}{}+ set, args := []string{}, []any{}if v := patch.UpdatedTs; v != nil {set, args = append(set, "updated_ts = ?"), append(args, *v)@@ -272,7 +272,7 @@ func patchUser(ctx context.Context, tx *sql.Tx, patch *api.UserPatch) (*userRaw,}func findUserList(ctx context.Context, tx *sql.Tx, find *api.UserFind) ([]*userRaw, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if v := find.ID; v != nil {where, args = append(where, "id = ?"), append(args, *v)diff --git a/store/user_setting.go b/store/user_setting.goindex 2782defde..641574f44 100644--- a/store/user_setting.go+++ b/store/user_setting.go@@ -118,7 +118,7 @@ func upsertUserSetting(ctx context.Context, tx *sql.Tx, upsert *api.UserSettingU}func findUserSettingList(ctx context.Context, tx *sql.Tx, find *api.UserSettingFind) ([]*userSettingRaw, error) {- where, args := []string{"1 = 1"}, []interface{}{}+ where, args := []string{"1 = 1"}, []any{}if v := find.Key.String(); v != "" {where, args = append(where, "key = ?"), append(args, v)