chore: fix linter errors

This commit is contained in:
Johnny
2025-04-05 22:36:02 +08:00
parent 9c7b063d72
commit 516487b58a
7 changed files with 17 additions and 9 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ func GetImage(urlStr string) (*Image, error) {
return nil, err return nil, err
} }
if !strings.HasPrefix(mediatype, "image/") { if !strings.HasPrefix(mediatype, "image/") {
return nil, errors.New("Wrong image mediatype") return nil, errors.New("wrong image mediatype")
} }
bodyBytes, err := io.ReadAll(response.Body) bodyBytes, err := io.ReadAll(response.Body)
+1 -1
View File
@@ -34,7 +34,7 @@ func GetSchemaVersion(version string) string {
return minorVersion + ".0" return minorVersion + ".0"
} }
// IsVersionGreaterThanOrEqualTo returns true if version is greater than or equal to target. // IsVersionGreaterOrEqualThan returns true if version is greater than or equal to target.
func IsVersionGreaterOrEqualThan(version, target string) bool { func IsVersionGreaterOrEqualThan(version, target string) bool {
return semver.Compare(fmt.Sprintf("v%s", version), fmt.Sprintf("v%s", target)) > -1 return semver.Compare(fmt.Sprintf("v%s", version), fmt.Sprintf("v%s", target)) > -1
} }
+3 -1
View File
@@ -62,7 +62,9 @@ func (s *Store) ListShortcuts(ctx context.Context, find *FindShortcut) ([]*store
func (s *Store) GetShortcut(ctx context.Context, find *FindShortcut) (*storepb.Shortcut, error) { func (s *Store) GetShortcut(ctx context.Context, find *FindShortcut) (*storepb.Shortcut, error) {
if find.ID != nil { if find.ID != nil {
if cache, ok := s.shortcutCache.Load(*find.ID); ok { if cache, ok := s.shortcutCache.Load(*find.ID); ok {
return cache.(*storepb.Shortcut), nil if shortcut, ok := cache.(*storepb.Shortcut); ok {
return shortcut, nil
}
} }
} }
+3 -1
View File
@@ -85,7 +85,9 @@ func (s *Store) ListUsers(ctx context.Context, find *FindUser) ([]*User, error)
func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error) { func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error) {
if find.ID != nil { if find.ID != nil {
if cache, ok := s.userCache.Load(*find.ID); ok { if cache, ok := s.userCache.Load(*find.ID); ok {
return cache.(*User), nil if user, ok := cache.(*User); ok {
return user, nil
}
} }
} }
+3 -1
View File
@@ -35,7 +35,9 @@ func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]
func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error) { func (s *Store) GetUserSetting(ctx context.Context, find *FindUserSetting) (*storepb.UserSetting, error) {
if find.UserID != nil && find.Key != storepb.UserSettingKey_USER_SETTING_KEY_UNSPECIFIED { if find.UserID != nil && find.Key != storepb.UserSettingKey_USER_SETTING_KEY_UNSPECIFIED {
if cache, ok := s.userSettingCache.Load(getUserSettingCacheKey(*find.UserID, find.Key.String())); ok { if cache, ok := s.userSettingCache.Load(getUserSettingCacheKey(*find.UserID, find.Key.String())); ok {
return cache.(*storepb.UserSetting), nil if userSetting, ok := cache.(*storepb.UserSetting); ok {
return userSetting, nil
}
} }
} }
+3 -1
View File
@@ -35,7 +35,9 @@ func (s *Store) ListWorkspaceSettings(ctx context.Context, find *FindWorkspaceSe
func (s *Store) GetWorkspaceSetting(ctx context.Context, find *FindWorkspaceSetting) (*storepb.WorkspaceSetting, error) { func (s *Store) GetWorkspaceSetting(ctx context.Context, find *FindWorkspaceSetting) (*storepb.WorkspaceSetting, error) {
if find.Key != storepb.WorkspaceSettingKey_WORKSPACE_SETTING_KEY_UNSPECIFIED { if find.Key != storepb.WorkspaceSettingKey_WORKSPACE_SETTING_KEY_UNSPECIFIED {
if cache, ok := s.workspaceSettingCache.Load(find.Key); ok { if cache, ok := s.workspaceSettingCache.Load(find.Key); ok {
return cache.(*storepb.WorkspaceSetting), nil if workspaceSetting, ok := cache.(*storepb.WorkspaceSetting); ok {
return workspaceSetting, nil
}
} }
} }
+3 -3
View File
@@ -31,15 +31,15 @@ func TestCollectionStore(t *testing.T) {
require.Equal(t, 1, len(collections)) require.Equal(t, 1, len(collections))
require.Equal(t, collection, collections[0]) require.Equal(t, collection, collections[0])
newTitle := "My new collection" newTitle := "My new collection"
newShortcutIds := []int32{101, 103} newShortcutIDs := []int32{101, 103}
updatedCollection, err := ts.UpdateCollection(ctx, &store.UpdateCollection{ updatedCollection, err := ts.UpdateCollection(ctx, &store.UpdateCollection{
ID: collection.Id, ID: collection.Id,
Title: &newTitle, Title: &newTitle,
ShortcutIDs: newShortcutIds, ShortcutIDs: newShortcutIDs,
}) })
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, newTitle, updatedCollection.Title) require.Equal(t, newTitle, updatedCollection.Title)
require.Equal(t, newShortcutIds, updatedCollection.ShortcutIds) require.Equal(t, newShortcutIDs, updatedCollection.ShortcutIds)
err = ts.DeleteCollection(ctx, &store.DeleteCollection{ err = ts.DeleteCollection(ctx, &store.DeleteCollection{
ID: collection.Id, ID: collection.Id,
}) })