diff --git a/server/.golangci.yml b/server/.golangci.yml index a819583e7e..87c2c40aa7 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -4,6 +4,9 @@ run: linters-settings: gofmt: simplify: true + rewrite-rules: + - pattern: 'interface{}' + replacement: 'any' govet: enable-all: true disable: @@ -54,6 +57,10 @@ issues: - staticcheck text: SA1019 + - linters: + - gofmt + path: "mock.*" + - linters: - errcheck path: "\ diff --git a/server/channels/store/sqlstore/channel_store.go b/server/channels/store/sqlstore/channel_store.go index 2c6edd1296..e1da7ac075 100644 --- a/server/channels/store/sqlstore/channel_store.go +++ b/server/channels/store/sqlstore/channel_store.go @@ -140,8 +140,8 @@ func channelSliceColumns(prefix ...string) []string { } } -func channelToSlice(channel *model.Channel) []interface{} { - return []interface{}{ +func channelToSlice(channel *model.Channel) []any { + return []any{ channel.Id, channel.CreateAt, channel.UpdateAt, diff --git a/server/public/model/bot.go b/server/public/model/bot.go index 4c869852f5..2370f04b2b 100644 --- a/server/public/model/bot.go +++ b/server/public/model/bot.go @@ -33,8 +33,8 @@ type Bot struct { DeleteAt int64 `json:"delete_at"` } -func (b *Bot) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (b *Bot) Auditable() map[string]any { + return map[string]any{ "user_id": b.UserId, "username": b.Username, "display_name": b.DisplayName, @@ -54,8 +54,8 @@ type BotPatch struct { Description *string `json:"description"` } -func (b *BotPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (b *BotPatch) Auditable() map[string]any { + return map[string]any{ "username": b.Username, "display_name": b.DisplayName, "description": b.Description, diff --git a/server/public/model/channel.go b/server/public/model/channel.go index 536bc1236c..a362ed6b5c 100644 --- a/server/public/model/channel.go +++ b/server/public/model/channel.go @@ -46,7 +46,7 @@ type ChannelBannerInfo struct { BackgroundColor *string `json:"background_color"` } -func (c *ChannelBannerInfo) Scan(value interface{}) error { +func (c *ChannelBannerInfo) Scan(value any) error { if value == nil { return nil } @@ -96,8 +96,8 @@ type Channel struct { BannerInfo *ChannelBannerInfo `json:"banner_info"` } -func (o *Channel) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *Channel) Auditable() map[string]any { + return map[string]any{ "create_at": o.CreateAt, "creator_id": o.CreatorId, "delete_at": o.DeleteAt, @@ -142,8 +142,8 @@ type ChannelPatch struct { BannerInfo *ChannelBannerInfo `json:"banner_info"` } -func (c *ChannelPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (c *ChannelPatch) Auditable() map[string]any { + return map[string]any{ "header": c.Header, "group_constrained": c.GroupConstrained, "purpose": c.Purpose, @@ -181,8 +181,8 @@ type ChannelModerationPatch struct { Roles *ChannelModeratedRolesPatch `json:"roles"` } -func (c *ChannelModerationPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (c *ChannelModerationPatch) Auditable() map[string]any { + return map[string]any{ "name": c.Name, "roles": c.Roles, } diff --git a/server/public/model/channel_bookmark.go b/server/public/model/channel_bookmark.go index f8bb7391bf..3b707a35f1 100644 --- a/server/public/model/channel_bookmark.go +++ b/server/public/model/channel_bookmark.go @@ -38,8 +38,8 @@ type ChannelBookmark struct { ParentId string `json:"parent_id,omitempty"` } -func (o *ChannelBookmark) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *ChannelBookmark) Auditable() map[string]any { + return map[string]any{ "id": o.Id, "create_at": o.CreateAt, "update_at": o.UpdateAt, @@ -193,8 +193,8 @@ type ChannelBookmarkPatch struct { Emoji *string `json:"emoji,omitempty"` } -func (o *ChannelBookmarkPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *ChannelBookmarkPatch) Auditable() map[string]any { + return map[string]any{ "file_id": o.FileId, } } @@ -226,7 +226,7 @@ type ChannelBookmarkWithFileInfo struct { FileInfo *FileInfo `json:"file,omitempty"` } -func (o *ChannelBookmarkWithFileInfo) Auditable() map[string]interface{} { +func (o *ChannelBookmarkWithFileInfo) Auditable() map[string]any { a := o.ChannelBookmark.Auditable() if o.FileInfo != nil { a["file"] = o.FileInfo.Auditable() diff --git a/server/public/model/channel_member.go b/server/public/model/channel_member.go index 492b8ed08b..defbb87df2 100644 --- a/server/public/model/channel_member.go +++ b/server/public/model/channel_member.go @@ -69,8 +69,8 @@ type ChannelMember struct { ExplicitRoles string `json:"explicit_roles"` } -func (o *ChannelMember) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *ChannelMember) Auditable() map[string]any { + return map[string]any{ "channel_id": o.ChannelId, "user_id": o.UserId, "roles": o.Roles, diff --git a/server/public/model/command.go b/server/public/model/command.go index 4d4bb3bb80..d48fee8f33 100644 --- a/server/public/model/command.go +++ b/server/public/model/command.go @@ -41,8 +41,8 @@ type Command struct { AutocompleteIconData string `db:"-" json:"autocomplete_icon_data,omitempty"` } -func (o *Command) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *Command) Auditable() map[string]any { + return map[string]any{ "id": o.Id, "create_at": o.CreateAt, "update_at": o.UpdateAt, diff --git a/server/public/model/command_args.go b/server/public/model/command_args.go index c7c9eaf579..24781c98c0 100644 --- a/server/public/model/command_args.go +++ b/server/public/model/command_args.go @@ -21,8 +21,8 @@ type CommandArgs struct { ChannelMentions ChannelMentionMap `json:"-"` } -func (o *CommandArgs) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *CommandArgs) Auditable() map[string]any { + return map[string]any{ "user_id": o.UserId, "channel_id": o.ChannelId, "team_id": o.TeamId, diff --git a/server/public/model/compliance.go b/server/public/model/compliance.go index c8c67f3891..d91267aecd 100644 --- a/server/public/model/compliance.go +++ b/server/public/model/compliance.go @@ -35,8 +35,8 @@ type Compliance struct { Emails string `json:"emails"` } -func (c *Compliance) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (c *Compliance) Auditable() map[string]any { + return map[string]any{ "id": c.Id, "create_at": c.CreateAt, "user_id": c.UserId, diff --git a/server/public/model/config.go b/server/public/model/config.go index 00a9e8dfdc..670301aefb 100644 --- a/server/public/model/config.go +++ b/server/public/model/config.go @@ -3741,8 +3741,8 @@ type Config struct { ConnectedWorkspacesSettings ConnectedWorkspacesSettings } -func (o *Config) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *Config) Auditable() map[string]any { + return map[string]any{ // TODO } } diff --git a/server/public/model/data_retention_policy.go b/server/public/model/data_retention_policy.go index 8d48d0dca5..8da6606b02 100644 --- a/server/public/model/data_retention_policy.go +++ b/server/public/model/data_retention_policy.go @@ -22,8 +22,8 @@ type RetentionPolicyWithTeamAndChannelIDs struct { ChannelIDs []string `json:"channel_ids"` } -func (o *RetentionPolicyWithTeamAndChannelIDs) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *RetentionPolicyWithTeamAndChannelIDs) Auditable() map[string]any { + return map[string]any{ "retention_policy": o.RetentionPolicy, "team_ids": o.TeamIDs, "channel_ids": o.ChannelIDs, @@ -36,8 +36,8 @@ type RetentionPolicyWithTeamAndChannelCounts struct { TeamCount int64 `json:"team_count"` } -func (o *RetentionPolicyWithTeamAndChannelCounts) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *RetentionPolicyWithTeamAndChannelCounts) Auditable() map[string]any { + return map[string]any{ "retention_policy": o.RetentionPolicy, "channel_count": o.ChannelCount, "team_count": o.TeamCount, diff --git a/server/public/model/draft.go b/server/public/model/draft.go index 53035497e0..eb5640ab9d 100644 --- a/server/public/model/draft.go +++ b/server/public/model/draft.go @@ -97,7 +97,7 @@ func (o *Draft) PreSave() { func (o *Draft) PreCommit() { if o.GetProps() == nil { - o.SetProps(make(map[string]interface{})) + o.SetProps(make(map[string]any)) } if o.FileIds == nil { diff --git a/server/public/model/emoji.go b/server/public/model/emoji.go index 9ec2cd1e2f..bb659c506c 100644 --- a/server/public/model/emoji.go +++ b/server/public/model/emoji.go @@ -25,8 +25,8 @@ type Emoji struct { Name string `json:"name"` } -func (emoji *Emoji) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (emoji *Emoji) Auditable() map[string]any { + return map[string]any{ "id": emoji.Id, "create_at": emoji.CreateAt, "update_at": emoji.UpdateAt, diff --git a/server/public/model/file_info.go b/server/public/model/file_info.go index 38c764d13d..7be518c994 100644 --- a/server/public/model/file_info.go +++ b/server/public/model/file_info.go @@ -59,8 +59,8 @@ type FileInfo struct { Archived bool `json:"archived"` } -func (fi *FileInfo) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (fi *FileInfo) Auditable() map[string]any { + return map[string]any{ "id": fi.Id, "creator_id": fi.CreatorId, "post_id": fi.PostId, diff --git a/server/public/model/group.go b/server/public/model/group.go index 3dcd0f658d..191329c674 100644 --- a/server/public/model/group.go +++ b/server/public/model/group.go @@ -43,8 +43,8 @@ type Group struct { MemberIDs []string `db:"-" json:"member_ids"` } -func (group *Group) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (group *Group) Auditable() map[string]any { + return map[string]any{ "id": group.Id, "source": group.Source, "remote_id": group.GetRemoteId(), @@ -58,7 +58,7 @@ func (group *Group) Auditable() map[string]interface{} { } func (group *Group) LogClone() any { - return map[string]interface{}{ + return map[string]any{ "id": group.Id, "name": group.GetName(), "display_name": group.DisplayName, @@ -78,8 +78,8 @@ type GroupWithUserIds struct { UserIds []string `json:"user_ids"` } -func (group *GroupWithUserIds) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (group *GroupWithUserIds) Auditable() map[string]any { + return map[string]any{ "id": group.Id, "source": group.Source, "remote_id": group.GetRemoteId(), @@ -176,8 +176,8 @@ type GroupModifyMembers struct { UserIds []string `json:"user_ids"` } -func (group *GroupModifyMembers) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (group *GroupModifyMembers) Auditable() map[string]any { + return map[string]any{ "user_ids": group.UserIds, } } diff --git a/server/public/model/group_syncable.go b/server/public/model/group_syncable.go index 83df73bf12..28df18c4ed 100644 --- a/server/public/model/group_syncable.go +++ b/server/public/model/group_syncable.go @@ -42,8 +42,8 @@ type GroupSyncable struct { TeamID string `db:"-" json:"-"` } -func (syncable *GroupSyncable) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (syncable *GroupSyncable) Auditable() map[string]any { + return map[string]any{ "group_id": syncable.GroupId, "syncable_id": syncable.SyncableId, "auto_add": syncable.AutoAdd, @@ -153,8 +153,8 @@ type GroupSyncablePatch struct { SchemeAdmin *bool `json:"scheme_admin"` } -func (syncable *GroupSyncablePatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (syncable *GroupSyncablePatch) Auditable() map[string]any { + return map[string]any{ "auto_add": syncable.AutoAdd, "scheme_admin": syncable.SchemeAdmin, } diff --git a/server/public/model/group_test.go b/server/public/model/group_test.go index 32f863c0b3..960133861b 100644 --- a/server/public/model/group_test.go +++ b/server/public/model/group_test.go @@ -55,7 +55,7 @@ func TestGroupLogClone(t *testing.T) { l := g.LogClone() require.NotNil(t, l) - m, ok := l.(map[string]interface{}) + m, ok := l.(map[string]any) require.True(t, ok) assert.Equal(t, "", m["remote_id"]) }) @@ -77,7 +77,7 @@ func TestGroupLogClone(t *testing.T) { AllowReference: true, } l := g.LogClone() - m, ok := l.(map[string]interface{}) + m, ok := l.(map[string]any) require.True(t, ok) expected := map[string]any{ diff --git a/server/public/model/guest_invite.go b/server/public/model/guest_invite.go index d187635beb..c41713061d 100644 --- a/server/public/model/guest_invite.go +++ b/server/public/model/guest_invite.go @@ -13,8 +13,8 @@ type GuestsInvite struct { Message string `json:"message"` } -func (i *GuestsInvite) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (i *GuestsInvite) Auditable() map[string]any { + return map[string]any{ "emails": i.Emails, "channels": i.Channels, } diff --git a/server/public/model/incoming_webhook.go b/server/public/model/incoming_webhook.go index 4fcdbf381e..66d09b7c4c 100644 --- a/server/public/model/incoming_webhook.go +++ b/server/public/model/incoming_webhook.go @@ -30,8 +30,8 @@ type IncomingWebhook struct { ChannelLocked bool `json:"channel_locked"` } -func (o *IncomingWebhook) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *IncomingWebhook) Auditable() map[string]any { + return map[string]any{ "id": o.Id, "create_at": o.CreateAt, "update_at": o.UpdateAt, diff --git a/server/public/model/ip_filtering.go b/server/public/model/ip_filtering.go index 75dda05697..6523af76c8 100644 --- a/server/public/model/ip_filtering.go +++ b/server/public/model/ip_filtering.go @@ -9,8 +9,8 @@ type AllowedIPRange struct { OwnerID string `json:"owner_id"` } -func (air *AllowedIPRanges) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (air *AllowedIPRanges) Auditable() map[string]any { + return map[string]any{ "AllowedIPRanges": air, } } diff --git a/server/public/model/job.go b/server/public/model/job.go index a9ca699bf7..f3df27b514 100644 --- a/server/public/model/job.go +++ b/server/public/model/job.go @@ -91,8 +91,8 @@ type Job struct { Data StringMap `json:"data"` } -func (j *Job) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (j *Job) Auditable() map[string]any { + return map[string]any{ "id": j.Id, "type": j.Type, "priority": j.Priority, @@ -129,7 +129,7 @@ func (j *Job) MarshalYAML() (any, error) { }, nil } -func (j *Job) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (j *Job) UnmarshalYAML(unmarshal func(any) error) error { out := struct { Id string `yaml:"id"` Type string `yaml:"type"` diff --git a/server/public/model/member_invite.go b/server/public/model/member_invite.go index 4aaf836ed2..4e4e59d5da 100644 --- a/server/public/model/member_invite.go +++ b/server/public/model/member_invite.go @@ -14,8 +14,8 @@ type MemberInvite struct { Message string `json:"message"` } -func (i *MemberInvite) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (i *MemberInvite) Auditable() map[string]any { + return map[string]any{ "emails": i.Emails, "channel_ids": i.ChannelIds, } diff --git a/server/public/model/oauth.go b/server/public/model/oauth.go index dc2c1bad6d..8bfdc2a982 100644 --- a/server/public/model/oauth.go +++ b/server/public/model/oauth.go @@ -32,8 +32,8 @@ type OAuthApp struct { MattermostAppID string `json:"mattermost_app_id"` } -func (a *OAuthApp) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (a *OAuthApp) Auditable() map[string]any { + return map[string]any{ "id": a.Id, "creator_id": a.CreatorId, "create_at": a.CreateAt, diff --git a/server/public/model/onboarding.go b/server/public/model/onboarding.go index 0fe5e91ffa..ea80bbff40 100644 --- a/server/public/model/onboarding.go +++ b/server/public/model/onboarding.go @@ -14,8 +14,8 @@ type CompleteOnboardingRequest struct { InstallPlugins []string `json:"install_plugins"` // InstallPlugins is a list of plugins to be installed } -func (r *CompleteOnboardingRequest) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (r *CompleteOnboardingRequest) Auditable() map[string]any { + return map[string]any{ "install_plugins": r.InstallPlugins, } } diff --git a/server/public/model/outgoing_oauth_connection.go b/server/public/model/outgoing_oauth_connection.go index ff4c41cf54..2c1363cd43 100644 --- a/server/public/model/outgoing_oauth_connection.go +++ b/server/public/model/outgoing_oauth_connection.go @@ -38,8 +38,8 @@ type OutgoingOAuthConnection struct { Audiences StringArray `json:"audiences"` } -func (oa *OutgoingOAuthConnection) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (oa *OutgoingOAuthConnection) Auditable() map[string]any { + return map[string]any{ "id": oa.Id, "creator_id": oa.CreatorId, "create_at": oa.CreateAt, diff --git a/server/public/model/outgoing_webhook.go b/server/public/model/outgoing_webhook.go index 3d7623672e..456ef3df87 100644 --- a/server/public/model/outgoing_webhook.go +++ b/server/public/model/outgoing_webhook.go @@ -30,8 +30,8 @@ type OutgoingWebhook struct { IconURL string `json:"icon_url"` } -func (o *OutgoingWebhook) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *OutgoingWebhook) Auditable() map[string]any { + return map[string]any{ "id": o.Id, "create_at": o.CreateAt, "update_at": o.UpdateAt, diff --git a/server/public/model/packet_metadata_test.go b/server/public/model/packet_metadata_test.go index 27b5c1a02b..5d81012055 100644 --- a/server/public/model/packet_metadata_test.go +++ b/server/public/model/packet_metadata_test.go @@ -25,7 +25,7 @@ func TestPacketMetadataValidate(t *testing.T) { ServerID: NewId(), LicenseID: NewId(), CustomerID: NewId(), - Extras: map[string]interface{}{"key": "value"}, + Extras: map[string]any{"key": "value"}, }, expectErr: false, }, @@ -36,7 +36,7 @@ func TestPacketMetadataValidate(t *testing.T) { GeneratedAt: 1720097114454, ServerVersion: "5.33.3", ServerID: NewId(), - Extras: map[string]interface{}{"key": "value"}, + Extras: map[string]any{"key": "value"}, }, expectErr: false, }, diff --git a/server/public/model/post.go b/server/public/model/post.go index fc12f386e2..7c77bc99f6 100644 --- a/server/public/model/post.go +++ b/server/public/model/post.go @@ -122,13 +122,13 @@ type Post struct { Metadata *PostMetadata `json:"metadata,omitempty"` } -func (o *Post) Auditable() map[string]interface{} { +func (o *Post) Auditable() map[string]any { var metaData map[string]any if o.Metadata != nil { metaData = o.Metadata.Auditable() } - return map[string]interface{}{ + return map[string]any{ "id": o.Id, "create_at": o.CreateAt, "update_at": o.UpdateAt, @@ -211,8 +211,8 @@ type SearchParameter struct { IncludeDeletedChannels *bool `json:"include_deleted_channels"` } -func (sp SearchParameter) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (sp SearchParameter) Auditable() map[string]any { + return map[string]any{ "terms": sp.Terms, "is_or_search": sp.IsOrSearch, "time_zone_offset": sp.TimeZoneOffset, @@ -240,8 +240,8 @@ func (o *PostPatch) WithRewrittenImageURLs(f func(string) string) *PostPatch { return &pCopy } -func (o *PostPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *PostPatch) Auditable() map[string]any { + return map[string]any{ "is_pinned": o.IsPinned, "props": o.Props, "file_ids": o.FileIds, diff --git a/server/public/model/post_search_results.go b/server/public/model/post_search_results.go index 782e7db76b..b9ae4d3baa 100644 --- a/server/public/model/post_search_results.go +++ b/server/public/model/post_search_results.go @@ -40,7 +40,7 @@ func (o *PostSearchResults) ForPlugin() *PostSearchResults { return &plCopy } -func (o *PostSearchResults) Auditable() map[string]interface{} { +func (o *PostSearchResults) Auditable() map[string]any { var numResults int var hasNext bool diff --git a/server/public/model/property_field.go b/server/public/model/property_field.go index fd439eee95..669ac275e6 100644 --- a/server/public/model/property_field.go +++ b/server/public/model/property_field.go @@ -35,8 +35,8 @@ type PropertyField struct { DeleteAt int64 `json:"delete_at"` } -func (pf *PropertyField) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (pf *PropertyField) Auditable() map[string]any { + return map[string]any{ "id": pf.ID, "group_id": pf.GroupID, "name": pf.Name, @@ -106,8 +106,8 @@ type PropertyFieldPatch struct { TargetType *string `json:"target_type"` } -func (pfp *PropertyFieldPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (pfp *PropertyFieldPatch) Auditable() map[string]any { + return map[string]any{ "name": pfp.Name, "type": pfp.Type, "attrs": pfp.Attrs, diff --git a/server/public/model/remote_cluster.go b/server/public/model/remote_cluster.go index adf1eb308f..2dde48b4fd 100644 --- a/server/public/model/remote_cluster.go +++ b/server/public/model/remote_cluster.go @@ -70,8 +70,8 @@ type RemoteCluster struct { Options Bitmask `json:"options"` // bit-flag set of options } -func (rc *RemoteCluster) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (rc *RemoteCluster) Auditable() map[string]any { + return map[string]any{ "remote_id": rc.RemoteId, "remote_team_id": rc.RemoteTeamId, "name": rc.Name, @@ -148,8 +148,8 @@ type RemoteClusterPatch struct { DefaultTeamId *string `json:"default_team_id"` } -func (rcp *RemoteClusterPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (rcp *RemoteClusterPatch) Auditable() map[string]any { + return map[string]any{ "display_name": rcp.DisplayName, "default_team_id": rcp.DefaultTeamId, } @@ -300,8 +300,8 @@ type RemoteClusterFrame struct { Msg RemoteClusterMsg `json:"msg"` } -func (f *RemoteClusterFrame) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (f *RemoteClusterFrame) Auditable() map[string]any { + return map[string]any{ "remote_id": f.RemoteId, "msg_id": f.Msg.Id, "topic": f.Msg.Topic, diff --git a/server/public/model/role.go b/server/public/model/role.go index eea9e16add..6fb0b6d8df 100644 --- a/server/public/model/role.go +++ b/server/public/model/role.go @@ -425,8 +425,8 @@ type Role struct { BuiltIn bool `json:"built_in"` } -func (r *Role) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (r *Role) Auditable() map[string]any { + return map[string]any{ "id": r.Id, "name": r.Name, "display_name": r.DisplayName, @@ -471,7 +471,7 @@ func (r *Role) MarshalYAML() (any, error) { }, nil } -func (r *Role) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (r *Role) UnmarshalYAML(unmarshal func(any) error) error { out := struct { Id string `yaml:"id"` Name string `yaml:"name"` @@ -522,8 +522,8 @@ type RolePatch struct { Permissions *[]string `json:"permissions"` } -func (r *RolePatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (r *RolePatch) Auditable() map[string]any { + return map[string]any{ "permissions": r.Permissions, } } diff --git a/server/public/model/scheduled_post.go b/server/public/model/scheduled_post.go index fadf5992ea..37384e2375 100644 --- a/server/public/model/scheduled_post.go +++ b/server/public/model/scheduled_post.go @@ -128,13 +128,13 @@ func (s *ScheduledPost) ToPost() (*Post, error) { return post, nil } -func (s *ScheduledPost) Auditable() map[string]interface{} { +func (s *ScheduledPost) Auditable() map[string]any { var metaData map[string]any if s.Metadata != nil { metaData = s.Metadata.Auditable() } - return map[string]interface{}{ + return map[string]any{ "id": s.Id, "create_at": s.CreateAt, "update_at": s.UpdateAt, diff --git a/server/public/model/scheme.go b/server/public/model/scheme.go index d85516e214..603821992c 100644 --- a/server/public/model/scheme.go +++ b/server/public/model/scheme.go @@ -41,8 +41,8 @@ type Scheme struct { DefaultRunMemberRole string `json:"default_run_member_role"` } -func (scheme *Scheme) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (scheme *Scheme) Auditable() map[string]any { + return map[string]any{ "id": scheme.Id, "name": scheme.Name, "display_name": scheme.DisplayName, @@ -112,7 +112,7 @@ func (scheme *Scheme) MarshalYAML() (any, error) { }, nil } -func (scheme *Scheme) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (scheme *Scheme) UnmarshalYAML(unmarshal func(any) error) error { out := struct { Id string `yaml:"id"` Name string `yaml:"name"` @@ -181,8 +181,8 @@ type SchemePatch struct { Description *string `json:"description"` } -func (scheme *SchemePatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (scheme *SchemePatch) Auditable() map[string]any { + return map[string]any{ "name": scheme.Name, "display_name": scheme.DisplayName, "description": scheme.Description, @@ -193,8 +193,8 @@ type SchemeIDPatch struct { SchemeID *string `json:"scheme_id"` } -func (p *SchemeIDPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (p *SchemeIDPatch) Auditable() map[string]any { + return map[string]any{ "scheme_id": p.SchemeID, } } @@ -243,8 +243,8 @@ type SchemeRoles struct { SchemeGuest bool `json:"scheme_guest"` } -func (s *SchemeRoles) Auditable() map[string]interface{} { - return map[string]interface{}{} +func (s *SchemeRoles) Auditable() map[string]any { + return map[string]any{} } func (scheme *Scheme) IsValid() bool { diff --git a/server/public/model/session.go b/server/public/model/session.go index 457c5cd922..351a60a668 100644 --- a/server/public/model/session.go +++ b/server/public/model/session.go @@ -68,8 +68,8 @@ type Session struct { Local bool `json:"local" db:"-"` } -func (s *Session) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (s *Session) Auditable() map[string]any { + return map[string]any{ "id": s.Id, "create_at": s.CreateAt, "expires_at": s.ExpiresAt, diff --git a/server/public/model/switch_request.go b/server/public/model/switch_request.go index f59115f5ba..12853f288a 100644 --- a/server/public/model/switch_request.go +++ b/server/public/model/switch_request.go @@ -13,8 +13,8 @@ type SwitchRequest struct { LdapLoginId string `json:"ldap_id"` } -func (o *SwitchRequest) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *SwitchRequest) Auditable() map[string]any { + return map[string]any{ "current_service": o.CurrentService, "new_service": o.NewService, "email": o.Email, diff --git a/server/public/model/team.go b/server/public/model/team.go index 6e48ac8cb8..9325ef2268 100644 --- a/server/public/model/team.go +++ b/server/public/model/team.go @@ -44,8 +44,8 @@ type Team struct { CloudLimitsArchived bool `json:"cloud_limits_archived"` } -func (o *Team) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *Team) Auditable() map[string]any { + return map[string]any{ "id": o.Id, "create_at": o.CreateAt, "update_at": o.UpdateAt, @@ -74,8 +74,8 @@ type TeamPatch struct { CloudLimitsArchived *bool `json:"cloud_limits_archived"` } -func (o *TeamPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *TeamPatch) Auditable() map[string]any { + return map[string]any{ "allow_open_invite": o.AllowOpenInvite, "group_constrained": o.GroupConstrained, "cloud_limits_archived": o.CloudLimitsArchived, diff --git a/server/public/model/team_member.go b/server/public/model/team_member.go index 276777eb04..53cf25f072 100644 --- a/server/public/model/team_member.go +++ b/server/public/model/team_member.go @@ -29,8 +29,8 @@ type TeamMember struct { CreateAt int64 `json:"-"` } -func (o *TeamMember) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (o *TeamMember) Auditable() map[string]any { + return map[string]any{ "team_id": o.TeamId, "user_id": o.UserId, "roles": o.Roles, diff --git a/server/public/model/upload_session.go b/server/public/model/upload_session.go index 9181c3e3e9..7bfe4248a1 100644 --- a/server/public/model/upload_session.go +++ b/server/public/model/upload_session.go @@ -47,8 +47,8 @@ type UploadSession struct { ReqFileId string `json:"req_file_id"` } -func (us *UploadSession) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (us *UploadSession) Auditable() map[string]any { + return map[string]any{ "id": us.Id, "type": us.Type, "user_id": us.UserId, diff --git a/server/public/model/user.go b/server/public/model/user.go index 6002c6e3d4..3805d30450 100644 --- a/server/public/model/user.go +++ b/server/public/model/user.go @@ -112,8 +112,8 @@ type User struct { MfaUsedTimestamps StringArray `json:"mfa_used_timestamps,omitempty"` } -func (u *User) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (u *User) Auditable() map[string]any { + return map[string]any{ "id": u.Id, "create_at": u.CreateAt, "update_at": u.UpdateAt, @@ -145,7 +145,7 @@ func (u *User) Auditable() map[string]interface{} { } func (u *User) LogClone() any { - return map[string]interface{}{ + return map[string]any{ "id": u.Id, "create_at": u.CreateAt, "update_at": u.UpdateAt, @@ -195,8 +195,8 @@ type UserPatch struct { RemoteId *string `json:"remote_id"` } -func (u *UserPatch) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (u *UserPatch) Auditable() map[string]any { + return map[string]any{ "username": u.Username, "nickname": u.Nickname, "first_name": u.FirstName, @@ -217,8 +217,8 @@ type UserAuth struct { AuthService string `json:"auth_service,omitempty"` } -func (u *UserAuth) Auditable() map[string]interface{} { - return map[string]interface{}{ +func (u *UserAuth) Auditable() map[string]any { + return map[string]any{ "auth_service": u.AuthService, } } diff --git a/server/public/model/user_test.go b/server/public/model/user_test.go index 17af85f03d..ac4296ca75 100644 --- a/server/public/model/user_test.go +++ b/server/public/model/user_test.go @@ -99,7 +99,7 @@ func TestUserLogClone(t *testing.T) { l := u.LogClone() require.NotNil(t, l) - m, ok := l.(map[string]interface{}) + m, ok := l.(map[string]any) require.True(t, ok) assert.Equal(t, "", m["remote_id"]) }) @@ -135,7 +135,7 @@ func TestUserLogClone(t *testing.T) { } l := u.LogClone() - m, ok := l.(map[string]interface{}) + m, ok := l.(map[string]any) require.True(t, ok) expected := map[string]any{ diff --git a/server/public/plugin/checker/internal/test/missing/missing.go b/server/public/plugin/checker/internal/test/missing/missing.go index f2cfc8eade..d18e07be52 100644 --- a/server/public/plugin/checker/internal/test/missing/missing.go +++ b/server/public/plugin/checker/internal/test/missing/missing.go @@ -4,5 +4,4 @@ package missing // SomeType is a fake interface for testing the plugin comment checker. -type SomeType interface { -} +type SomeType any diff --git a/server/public/pluginapi/cluster/mutex.go b/server/public/pluginapi/cluster/mutex.go index 0169d3b398..5b337c811c 100644 --- a/server/public/pluginapi/cluster/mutex.go +++ b/server/public/pluginapi/cluster/mutex.go @@ -26,7 +26,7 @@ const ( // MutexPluginAPI is the plugin API interface required to manage mutexes. type MutexPluginAPI interface { KVSetWithOptions(key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError) - LogError(msg string, keyValuePairs ...interface{}) + LogError(msg string, keyValuePairs ...any) } // Mutex is similar to sync.Mutex, except usable by multiple plugin instances across a cluster. diff --git a/server/public/pluginapi/configuration.go b/server/public/pluginapi/configuration.go index f28cfe55e8..b78f0634ed 100644 --- a/server/public/pluginapi/configuration.go +++ b/server/public/pluginapi/configuration.go @@ -14,7 +14,7 @@ type ConfigurationService struct { // struct to which the configuration JSON can be unmarshalled. // // Minimum server version: 5.2 -func (c *ConfigurationService) LoadPluginConfiguration(dest interface{}) error { +func (c *ConfigurationService) LoadPluginConfiguration(dest any) error { // TODO: Isn't this method redundant given GetPluginConfig() and even GetConfig()? return c.api.LoadPluginConfiguration(dest) } @@ -43,13 +43,13 @@ func (c *ConfigurationService) SaveConfig(cfg *model.Config) error { // GetPluginConfig fetches the currently persisted config of plugin // // Minimum server version: 5.6 -func (c *ConfigurationService) GetPluginConfig() map[string]interface{} { +func (c *ConfigurationService) GetPluginConfig() map[string]any { return c.api.GetPluginConfig() } // SavePluginConfig sets the given config for plugin and persists the changes // // Minimum server version: 5.6 -func (c *ConfigurationService) SavePluginConfig(cfg map[string]interface{}) error { +func (c *ConfigurationService) SavePluginConfig(cfg map[string]any) error { return normalizeAppErr(c.api.SavePluginConfig(cfg)) } diff --git a/server/public/pluginapi/experimental/bot/logger/admincclogger/admincc_logger.go b/server/public/pluginapi/experimental/bot/logger/admincclogger/admincc_logger.go index b3c549e75e..961a5ace0b 100644 --- a/server/public/pluginapi/experimental/bot/logger/admincclogger/admincc_logger.go +++ b/server/public/pluginapi/experimental/bot/logger/admincclogger/admincc_logger.go @@ -46,7 +46,7 @@ func NewFromAPI(api common.LogAPI, dmer poster.DMer, logLevel logger.LogLevel, i return New(logger.New(api), dmer, logLevel, includeContext, userIDs...) } -func (l *adminCCLogger) Debugf(format string, args ...interface{}) { +func (l *adminCCLogger) Debugf(format string, args ...any) { l.Logger.Debugf(format, args...) message := fmt.Sprintf(format, args...) if logger.Level(l.logLevel) >= 4 { @@ -54,7 +54,7 @@ func (l *adminCCLogger) Debugf(format string, args ...interface{}) { } } -func (l *adminCCLogger) Errorf(format string, args ...interface{}) { +func (l *adminCCLogger) Errorf(format string, args ...any) { l.Logger.Errorf(format, args...) message := fmt.Sprintf(format, args...) if logger.Level(l.logLevel) >= 1 { @@ -62,7 +62,7 @@ func (l *adminCCLogger) Errorf(format string, args ...interface{}) { } } -func (l *adminCCLogger) Infof(format string, args ...interface{}) { +func (l *adminCCLogger) Infof(format string, args ...any) { l.Logger.Infof(format, args...) message := fmt.Sprintf(format, args...) if logger.Level(l.logLevel) >= 3 { @@ -70,7 +70,7 @@ func (l *adminCCLogger) Infof(format string, args ...interface{}) { } } -func (l *adminCCLogger) Warnf(format string, args ...interface{}) { +func (l *adminCCLogger) Warnf(format string, args ...any) { l.Logger.Warnf(format, args...) message := fmt.Sprintf(format, args...) if logger.Level(l.logLevel) >= 2 { @@ -86,7 +86,7 @@ func (l *adminCCLogger) logToAdmins(level, message string) { _ = l.dmAdmins("(log " + level + ") " + message) } -func (l *adminCCLogger) dmAdmins(format string, args ...interface{}) error { +func (l *adminCCLogger) dmAdmins(format string, args ...any) error { for _, id := range l.userIDs { _, err := l.dmer.DM(id, format, args) if err != nil { diff --git a/server/public/pluginapi/experimental/bot/logger/default_logger.go b/server/public/pluginapi/experimental/bot/logger/default_logger.go index e51adf8069..d9a02e0c1f 100644 --- a/server/public/pluginapi/experimental/bot/logger/default_logger.go +++ b/server/public/pluginapi/experimental/bot/logger/default_logger.go @@ -30,7 +30,7 @@ func New(api common.LogAPI) Logger { func (l *defaultLogger) With(logContext LogContext) Logger { newLogger := *l if len(newLogger.logContext) == 0 { - newLogger.logContext = map[string]interface{}{} + newLogger.logContext = map[string]any{} } for k, v := range logContext { newLogger.logContext[k] = v @@ -41,7 +41,7 @@ func (l *defaultLogger) With(logContext LogContext) Logger { func (l *defaultLogger) WithError(err error) Logger { newLogger := *l if len(newLogger.logContext) == 0 { - newLogger.logContext = map[string]interface{}{} + newLogger.logContext = map[string]any{} } newLogger.logContext[ErrorKey] = err.Error() return &newLogger @@ -57,25 +57,25 @@ func (l *defaultLogger) Timed() Logger { }) } -func (l *defaultLogger) Debugf(format string, args ...interface{}) { +func (l *defaultLogger) Debugf(format string, args ...any) { measure(l.logContext) message := fmt.Sprintf(format, args...) l.logAPI.LogDebug(message, toKeyValuePairs(l.logContext)...) } -func (l *defaultLogger) Errorf(format string, args ...interface{}) { +func (l *defaultLogger) Errorf(format string, args ...any) { measure(l.logContext) message := fmt.Sprintf(format, args...) l.logAPI.LogError(message, toKeyValuePairs(l.logContext)...) } -func (l *defaultLogger) Infof(format string, args ...interface{}) { +func (l *defaultLogger) Infof(format string, args ...any) { measure(l.logContext) message := fmt.Sprintf(format, args...) l.logAPI.LogInfo(message, toKeyValuePairs(l.logContext)...) } -func (l *defaultLogger) Warnf(format string, args ...interface{}) { +func (l *defaultLogger) Warnf(format string, args ...any) { measure(l.logContext) message := fmt.Sprintf(format, args...) l.logAPI.LogWarn(message, toKeyValuePairs(l.logContext)...) diff --git a/server/public/pluginapi/experimental/bot/logger/logger.go b/server/public/pluginapi/experimental/bot/logger/logger.go index 71e3924c1b..31886efd63 100644 --- a/server/public/pluginapi/experimental/bot/logger/logger.go +++ b/server/public/pluginapi/experimental/bot/logger/logger.go @@ -24,7 +24,7 @@ const ( ) // LogContext defines the context for the logs. -type LogContext map[string]interface{} +type LogContext map[string]any // Logger defines an object able to log messages. type Logger interface { @@ -37,13 +37,13 @@ type Logger interface { // Timed add a timed log context. Timed() Logger // Debugf logs a formatted string as a debug message. - Debugf(format string, args ...interface{}) + Debugf(format string, args ...any) // Errorf logs a formatted string as an error message. - Errorf(format string, args ...interface{}) + Errorf(format string, args ...any) // Infof logs a formatted string as an info message. - Infof(format string, args ...interface{}) + Infof(format string, args ...any) // Warnf logs a formatted string as an warning message. - Warnf(format string, args ...interface{}) + Warnf(format string, args ...any) } func measure(lc LogContext) { @@ -70,7 +70,7 @@ func Level(l LogLevel) int { return 0 } -func toKeyValuePairs(in map[string]interface{}) (out []interface{}) { +func toKeyValuePairs(in map[string]any) (out []any) { for k, v := range in { out = append(out, k, v) } diff --git a/server/public/pluginapi/experimental/bot/logger/nil_logger.go b/server/public/pluginapi/experimental/bot/logger/nil_logger.go index 45beac83c2..60dc3ddcbc 100644 --- a/server/public/pluginapi/experimental/bot/logger/nil_logger.go +++ b/server/public/pluginapi/experimental/bot/logger/nil_logger.go @@ -7,11 +7,11 @@ func NewNilLogger() Logger { return &nilLogger{} } -func (l *nilLogger) With(LogContext) Logger { return l } -func (l *nilLogger) WithError(error) Logger { return l } -func (l *nilLogger) Context() LogContext { return nil } -func (l *nilLogger) Timed() Logger { return l } -func (l *nilLogger) Debugf(string, ...interface{}) {} -func (l *nilLogger) Errorf(string, ...interface{}) {} -func (l *nilLogger) Infof(string, ...interface{}) {} -func (l *nilLogger) Warnf(string, ...interface{}) {} +func (l *nilLogger) With(LogContext) Logger { return l } +func (l *nilLogger) WithError(error) Logger { return l } +func (l *nilLogger) Context() LogContext { return nil } +func (l *nilLogger) Timed() Logger { return l } +func (l *nilLogger) Debugf(string, ...any) {} +func (l *nilLogger) Errorf(string, ...any) {} +func (l *nilLogger) Infof(string, ...any) {} +func (l *nilLogger) Warnf(string, ...any) {} diff --git a/server/public/pluginapi/experimental/bot/logger/telemetrylogger/telemetry_logger.go b/server/public/pluginapi/experimental/bot/logger/telemetrylogger/telemetry_logger.go index 8f6c802c8b..56fc2963a2 100644 --- a/server/public/pluginapi/experimental/bot/logger/telemetrylogger/telemetry_logger.go +++ b/server/public/pluginapi/experimental/bot/logger/telemetrylogger/telemetry_logger.go @@ -37,7 +37,7 @@ func NewFromAPI(api common.LogAPI, logLevel logger.LogLevel, tracker telemetry.T return New(logger.New(api), logLevel, tracker) } -func (l *telemetryLogger) Debugf(format string, args ...interface{}) { +func (l *telemetryLogger) Debugf(format string, args ...any) { l.Logger.Debugf(format, args...) message := fmt.Sprintf(format, args...) if logger.Level(l.logLevel) >= 4 { @@ -45,7 +45,7 @@ func (l *telemetryLogger) Debugf(format string, args ...interface{}) { } } -func (l *telemetryLogger) Errorf(format string, args ...interface{}) { +func (l *telemetryLogger) Errorf(format string, args ...any) { l.Logger.Errorf(format, args...) message := fmt.Sprintf(format, args...) if logger.Level(l.logLevel) >= 1 { @@ -53,7 +53,7 @@ func (l *telemetryLogger) Errorf(format string, args ...interface{}) { } } -func (l *telemetryLogger) Infof(format string, args ...interface{}) { +func (l *telemetryLogger) Infof(format string, args ...any) { l.Logger.Infof(format, args...) message := fmt.Sprintf(format, args...) if logger.Level(l.logLevel) >= 3 { @@ -61,7 +61,7 @@ func (l *telemetryLogger) Infof(format string, args ...interface{}) { } } -func (l *telemetryLogger) Warnf(format string, args ...interface{}) { +func (l *telemetryLogger) Warnf(format string, args ...any) { l.Logger.Warnf(format, args...) message := fmt.Sprintf(format, args...) if logger.Level(l.logLevel) >= 2 { @@ -70,7 +70,7 @@ func (l *telemetryLogger) Warnf(format string, args ...interface{}) { } func (l *telemetryLogger) logToTelemetry(level, message string) { - properties := map[string]interface{}{} + properties := map[string]any{} properties["message"] = message for k, v := range l.Context() { properties["context_"+k] = fmt.Sprintf("%v", v) diff --git a/server/public/pluginapi/experimental/bot/logger/test_logger.go b/server/public/pluginapi/experimental/bot/logger/test_logger.go index 2c8877059b..48584284a8 100644 --- a/server/public/pluginapi/experimental/bot/logger/test_logger.go +++ b/server/public/pluginapi/experimental/bot/logger/test_logger.go @@ -19,7 +19,7 @@ func NewTestLogger() Logger { func (l *testLogger) With(logContext LogContext) Logger { newl := *l if len(newl.logContext) == 0 { - newl.logContext = map[string]interface{}{} + newl.logContext = map[string]any{} } for k, v := range logContext { newl.logContext[k] = v @@ -30,7 +30,7 @@ func (l *testLogger) With(logContext LogContext) Logger { func (l *testLogger) WithError(err error) Logger { newl := *l if len(newl.logContext) == 0 { - newl.logContext = map[string]interface{}{} + newl.logContext = map[string]any{} } newl.logContext[ErrorKey] = err.Error() return &newl @@ -46,7 +46,7 @@ func (l *testLogger) Timed() Logger { }) } -func (l *testLogger) logf(prefix, format string, args ...interface{}) { +func (l *testLogger) logf(prefix, format string, args ...any) { out := fmt.Sprintf(prefix+": "+format, args...) if len(l.logContext) > 0 { measure(l.logContext) @@ -55,7 +55,7 @@ func (l *testLogger) logf(prefix, format string, args ...interface{}) { l.TB.Log(out) } -func (l *testLogger) Debugf(format string, args ...interface{}) { l.logf("DEBUG", format, args...) } -func (l *testLogger) Errorf(format string, args ...interface{}) { l.logf("ERROR", format, args...) } -func (l *testLogger) Infof(format string, args ...interface{}) { l.logf("INFO", format, args...) } -func (l *testLogger) Warnf(format string, args ...interface{}) { l.logf("WARN", format, args...) } +func (l *testLogger) Debugf(format string, args ...any) { l.logf("DEBUG", format, args...) } +func (l *testLogger) Errorf(format string, args ...any) { l.logf("ERROR", format, args...) } +func (l *testLogger) Infof(format string, args ...any) { l.logf("INFO", format, args...) } +func (l *testLogger) Warnf(format string, args ...any) { l.logf("WARN", format, args...) } diff --git a/server/public/pluginapi/experimental/bot/poster/default_poster.go b/server/public/pluginapi/experimental/bot/poster/default_poster.go index 16b9f45c2b..0394335b76 100644 --- a/server/public/pluginapi/experimental/bot/poster/default_poster.go +++ b/server/public/pluginapi/experimental/bot/poster/default_poster.go @@ -20,7 +20,7 @@ func NewPoster(postAPI PostAPI, id string) Poster { } // DM posts a simple Direct Message to the specified user -func (p *defaultPoster) DM(mattermostUserID, format string, args ...interface{}) (string, error) { +func (p *defaultPoster) DM(mattermostUserID, format string, args ...any) (string, error) { post := &model.Post{ Message: fmt.Sprintf(format, args...), } @@ -44,7 +44,7 @@ func (p *defaultPoster) DMWithAttachments(mattermostUserID string, attachments . } // Ephemeral sends an ephemeral message to a user -func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...interface{}) { +func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...any) { post := &model.Post{ UserId: p.id, ChannelId: channelID, @@ -53,7 +53,7 @@ func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...inte p.postAPI.SendEphemeralPost(userID, post) } -func (p *defaultPoster) UpdatePostByID(postID, format string, args ...interface{}) error { +func (p *defaultPoster) UpdatePostByID(postID, format string, args ...any) error { post, err := p.postAPI.GetPost(postID) if err != nil { return err diff --git a/server/public/pluginapi/experimental/bot/poster/default_poster_test.go b/server/public/pluginapi/experimental/bot/poster/default_poster_test.go index 9daa75f161..26fddfc467 100644 --- a/server/public/pluginapi/experimental/bot/poster/default_poster_test.go +++ b/server/public/pluginapi/experimental/bot/poster/default_poster_test.go @@ -30,7 +30,7 @@ func TestInterface(t *testing.T) { func TestDM(t *testing.T) { format := "test format, string: %s int: %d value: %v" - args := []interface{}{"some string", 5, 8.423} + args := []any{"some string", 5, 8.423} expectedMessage := "test format, string: some string int: 5 value: 8.423" expectedPostID := "expected-post-id" @@ -153,7 +153,7 @@ func TestDMWithAttachments(t *testing.T) { func TestEphemeral(t *testing.T) { format := "test format, string: %s int: %d value: %v" - args := []interface{}{"some string", 5, 8.423} + args := []any{"some string", 5, 8.423} expectedMessage := "test format, string: some string int: 5 value: 8.423" channelID := "some-channel" @@ -194,7 +194,7 @@ func TestEphemeral(t *testing.T) { func TestUpdatePostByID(t *testing.T) { format := "test format, string: %s int: %d value: %v" - args := []interface{}{"some string", 5, 8.423} + args := []any{"some string", 5, 8.423} expectedMessage := "test format, string: some string int: 5 value: 8.423" postID := "some-post-id" @@ -364,7 +364,7 @@ func TestUpdatePost(t *testing.T) { func TestUpdatePosterID(t *testing.T) { format := "test format, string: %s int: %d value: %v" - args := []interface{}{"some string", 5, 8.423} + args := []any{"some string", 5, 8.423} expectedMessage := "test format, string: some string int: 5 value: 8.423" expectedPostID := "expected-post-id" diff --git a/server/public/pluginapi/experimental/bot/poster/poster.go b/server/public/pluginapi/experimental/bot/poster/poster.go index 2fe032a7a3..ef87b8066a 100644 --- a/server/public/pluginapi/experimental/bot/poster/poster.go +++ b/server/public/pluginapi/experimental/bot/poster/poster.go @@ -16,10 +16,10 @@ type Poster interface { DMWithAttachments(mattermostUserID string, attachments ...*model.SlackAttachment) (string, error) // Ephemeral sends an ephemeral message to a user - Ephemeral(mattermostUserID, channelID, format string, args ...interface{}) + Ephemeral(mattermostUserID, channelID, format string, args ...any) // UpdatePostByID updates the post with postID with the formatted message - UpdatePostByID(postID, format string, args ...interface{}) error + UpdatePostByID(postID, format string, args ...any) error // DeletePost deletes a single post DeletePost(postID string) error @@ -34,5 +34,5 @@ type Poster interface { // DMer defines an entity that can send Direct Messages type DMer interface { // DM posts a simple Direct Message to the specified user - DM(mattermostUserID, format string, args ...interface{}) (string, error) + DM(mattermostUserID, format string, args ...any) (string, error) } diff --git a/server/public/pluginapi/experimental/common/kvstore.go b/server/public/pluginapi/experimental/common/kvstore.go index 9c2f7cdd88..e585138a95 100644 --- a/server/public/pluginapi/experimental/common/kvstore.go +++ b/server/public/pluginapi/experimental/common/kvstore.go @@ -9,8 +9,8 @@ import ( var ErrNotFound = errors.New("not found") type KVStore interface { - Set(key string, value interface{}, options ...pluginapi.KVSetOption) (bool, error) - Get(key string, o interface{}) error + Set(key string, value any, options ...pluginapi.KVSetOption) (bool, error) + Get(key string, o any) error Delete(key string) error DeleteAll() error ListKeys(page, count int, options ...pluginapi.ListKeysOption) ([]string, error) diff --git a/server/public/pluginapi/experimental/common/logapi.go b/server/public/pluginapi/experimental/common/logapi.go index 8613ef59a0..18a2295537 100644 --- a/server/public/pluginapi/experimental/common/logapi.go +++ b/server/public/pluginapi/experimental/common/logapi.go @@ -1,8 +1,8 @@ package common type LogAPI interface { - LogError(message string, keyValuePairs ...interface{}) - LogWarn(message string, keyValuePairs ...interface{}) - LogInfo(message string, keyValuePairs ...interface{}) - LogDebug(message string, keyValuePairs ...interface{}) + LogError(message string, keyValuePairs ...any) + LogWarn(message string, keyValuePairs ...any) + LogInfo(message string, keyValuePairs ...any) + LogDebug(message string, keyValuePairs ...any) } diff --git a/server/public/pluginapi/experimental/common/markdown.go b/server/public/pluginapi/experimental/common/markdown.go index 34d418dd97..dc9ecee685 100644 --- a/server/public/pluginapi/experimental/common/markdown.go +++ b/server/public/pluginapi/experimental/common/markdown.go @@ -8,7 +8,7 @@ import ( "fmt" ) -func JSON(ref interface{}) string { +func JSON(ref any) string { bb, _ := json.MarshalIndent(ref, "", " ") return string(bb) } @@ -17,6 +17,6 @@ func CodeBlock(in string) string { return fmt.Sprintf("\n```\n%s\n```\n", in) } -func JSONBlock(ref interface{}) string { +func JSONBlock(ref any) string { return fmt.Sprintf("\n```json\n%s\n```\n", JSON(ref)) } diff --git a/server/public/pluginapi/experimental/flow/flow.go b/server/public/pluginapi/experimental/flow/flow.go index 98fae8dcb7..64a981c49d 100644 --- a/server/public/pluginapi/experimental/flow/flow.go +++ b/server/public/pluginapi/experimental/flow/flow.go @@ -259,8 +259,8 @@ func Goto(toName Name) func(*Flow) (Name, State, error) { } } -func DialogGoto(toName Name) func(*Flow, map[string]interface{}) (Name, State, map[string]string, error) { - return func(_ *Flow, submitted map[string]interface{}) (Name, State, map[string]string, error) { +func DialogGoto(toName Name) func(*Flow, map[string]any) (Name, State, map[string]string, error) { + return func(_ *Flow, submitted map[string]any) (Name, State, map[string]string, error) { stateUpdate := State{} for k, v := range submitted { stateUpdate[k] = fmt.Sprintf("%v", v) diff --git a/server/public/pluginapi/experimental/flow/handler.go b/server/public/pluginapi/experimental/flow/handler.go index db2fac441c..14faf16053 100644 --- a/server/public/pluginapi/experimental/flow/handler.go +++ b/server/public/pluginapi/experimental/flow/handler.go @@ -97,7 +97,7 @@ func (f *Flow) handleButton(fromName Name, selectedButton int, triggerID string) } func (f *Flow) handleDialog( - fromName Name, selectedButton int, submission map[string]interface{}, + fromName Name, selectedButton int, submission map[string]any, ) ( *model.Post, map[string]string, error, ) { @@ -105,7 +105,7 @@ func (f *Flow) handleDialog( } func (f *Flow) handle( - fromName Name, selectedButton int, submission map[string]interface{}, triggerID string, asButton bool, + fromName Name, selectedButton int, submission map[string]any, triggerID string, asButton bool, ) ( *model.Post, map[string]string, error, ) { diff --git a/server/public/pluginapi/experimental/flow/state.go b/server/public/pluginapi/experimental/flow/state.go index e9393dc3c8..0920e8895a 100644 --- a/server/public/pluginapi/experimental/flow/state.go +++ b/server/public/pluginapi/experimental/flow/state.go @@ -9,7 +9,7 @@ import ( var errStateNotFound = errors.New("flow state not found") // State is the "app"'s state -type State map[string]interface{} +type State map[string]any func (s State) MergeWith(update State) State { n := State{} diff --git a/server/public/pluginapi/experimental/flow/step.go b/server/public/pluginapi/experimental/flow/step.go index f879d8c6e0..953c248632 100644 --- a/server/public/pluginapi/experimental/flow/step.go +++ b/server/public/pluginapi/experimental/flow/step.go @@ -50,7 +50,7 @@ type Button struct { // Function that is called when the dialog box is submitted. It can return a // general error, or field-specific errors. On success it returns the name // of the next step, and the state updates to apply. - OnDialogSubmit func(f *Flow, submitted map[string]interface{}) (Name, State, map[string]string, error) + OnDialogSubmit func(f *Flow, submitted map[string]any) (Name, State, map[string]string, error) } func NewStep(name Name) Step { @@ -229,7 +229,7 @@ func renderButton(b Button, stepName Name, i int, state State) *model.PostAction Disabled: b.Disabled, Style: string(b.Color), Integration: &model.PostActionIntegration{ - Context: map[string]interface{}{ + Context: map[string]any{ contextStepKey: string(stepName), contextButtonKey: strconv.Itoa(i), }, diff --git a/server/public/pluginapi/experimental/panel/panel.go b/server/public/pluginapi/experimental/panel/panel.go index e5e9582576..56ec11895f 100644 --- a/server/public/pluginapi/experimental/panel/panel.go +++ b/server/public/pluginapi/experimental/panel/panel.go @@ -11,7 +11,7 @@ import ( ) type Panel interface { - Set(userID, settingID string, value interface{}) error + Set(userID, settingID string, value any) error Print(userID string) ToPost(userID string) (*model.Post, error) Clear(userID string) error @@ -57,7 +57,7 @@ func NewSettingsPanel( return panel } -func (p *panel) Set(userID, settingID string, value interface{}) error { +func (p *panel) Set(userID, settingID string, value any) error { s, ok := p.settings[settingID] if !ok { return errors.New("cannot find setting " + settingID) diff --git a/server/public/pluginapi/experimental/panel/settings/base_setting.go b/server/public/pluginapi/experimental/panel/settings/base_setting.go index 96d533e578..e8018beb74 100644 --- a/server/public/pluginapi/experimental/panel/settings/base_setting.go +++ b/server/public/pluginapi/experimental/panel/settings/base_setting.go @@ -23,6 +23,6 @@ func (s *baseSetting) GetDependency() string { return s.dependsOn } -func (s *baseSetting) IsDisabled(foreignValue interface{}) bool { +func (s *baseSetting) IsDisabled(foreignValue any) bool { return false } diff --git a/server/public/pluginapi/experimental/panel/settings/bool_setting.go b/server/public/pluginapi/experimental/panel/settings/bool_setting.go index 0d7d9e9c36..4d8b6739e8 100644 --- a/server/public/pluginapi/experimental/panel/settings/bool_setting.go +++ b/server/public/pluginapi/experimental/panel/settings/bool_setting.go @@ -25,7 +25,7 @@ func NewBoolSetting(id, title, description, dependsOn string, store SettingStore } } -func (s *boolSetting) Set(userID string, value interface{}) error { +func (s *boolSetting) Set(userID string, value any) error { boolValue := false if value == TrueString { boolValue = true @@ -39,7 +39,7 @@ func (s *boolSetting) Set(userID string, value interface{}) error { return nil } -func (s *boolSetting) Get(userID string) (interface{}, error) { +func (s *boolSetting) Get(userID string) (any, error) { value, err := s.store.GetSetting(userID, s.id) if err != nil { return "", err @@ -79,7 +79,7 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable Name: "Yes", Integration: &model.PostActionIntegration{ URL: settingHandler, - Context: map[string]interface{}{ + Context: map[string]any{ ContextIDKey: s.id, ContextButtonValueKey: TrueString, }, @@ -91,7 +91,7 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable Name: "No", Integration: &model.PostActionIntegration{ URL: settingHandler, - Context: map[string]interface{}{ + Context: map[string]any{ ContextIDKey: s.id, ContextButtonValueKey: FalseString, }, @@ -111,6 +111,6 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable return &sa, nil } -func (s *boolSetting) IsDisabled(foreignValue interface{}) bool { +func (s *boolSetting) IsDisabled(foreignValue any) bool { return foreignValue == FalseString } diff --git a/server/public/pluginapi/experimental/panel/settings/empty_setting.go b/server/public/pluginapi/experimental/panel/settings/empty_setting.go index 61303a1960..ef81641f00 100644 --- a/server/public/pluginapi/experimental/panel/settings/empty_setting.go +++ b/server/public/pluginapi/experimental/panel/settings/empty_setting.go @@ -32,10 +32,10 @@ func (s *emptySetting) GetSlackAttachments(userID, settingHandler string, disabl return &sa, nil } -func (s *emptySetting) Get(userID string) (interface{}, error) { +func (s *emptySetting) Get(userID string) (any, error) { return nil, nil } -func (s *emptySetting) Set(userID string, value interface{}) error { +func (s *emptySetting) Set(userID string, value any) error { return nil } diff --git a/server/public/pluginapi/experimental/panel/settings/option_setting.go b/server/public/pluginapi/experimental/panel/settings/option_setting.go index 84dfcaf012..aec59bb6f1 100644 --- a/server/public/pluginapi/experimental/panel/settings/option_setting.go +++ b/server/public/pluginapi/experimental/panel/settings/option_setting.go @@ -27,7 +27,7 @@ func NewOptionSetting(id, title, description, dependsOn string, options []string } } -func (s *optionSetting) Set(userID string, value interface{}) error { +func (s *optionSetting) Set(userID string, value any) error { err := s.store.SetSetting(userID, s.id, value) if err != nil { return err @@ -36,7 +36,7 @@ func (s *optionSetting) Set(userID string, value interface{}) error { return nil } -func (s *optionSetting) Get(userID string) (interface{}, error) { +func (s *optionSetting) Get(userID string) (any, error) { value, err := s.store.GetSetting(userID, s.id) if err != nil { return "", err @@ -66,7 +66,7 @@ func (s *optionSetting) GetSlackAttachments(userID, settingHandler string, disab Name: "Select an option:", Integration: &model.PostActionIntegration{ URL: settingHandler + "?" + s.id + "=true", - Context: map[string]interface{}{ + Context: map[string]any{ ContextIDKey: s.id, }, }, @@ -86,6 +86,6 @@ func (s *optionSetting) GetSlackAttachments(userID, settingHandler string, disab return &sa, nil } -func (s *optionSetting) IsDisabled(foreignValue interface{}) bool { +func (s *optionSetting) IsDisabled(foreignValue any) bool { return foreignValue == FalseString } diff --git a/server/public/pluginapi/experimental/panel/settings/read_only_setting.go b/server/public/pluginapi/experimental/panel/settings/read_only_setting.go index 3604b4e5d3..25828a3318 100644 --- a/server/public/pluginapi/experimental/panel/settings/read_only_setting.go +++ b/server/public/pluginapi/experimental/panel/settings/read_only_setting.go @@ -25,7 +25,7 @@ func NewReadOnlySetting(id, title, description, dependsOn string, store SettingS } } -func (s *readOnlySetting) Get(userID string) (interface{}, error) { +func (s *readOnlySetting) Get(userID string) (any, error) { value, err := s.store.GetSetting(userID, s.id) if err != nil { return "", err @@ -38,7 +38,7 @@ func (s *readOnlySetting) Get(userID string) (interface{}, error) { return stringValue, nil } -func (s *readOnlySetting) Set(userID string, value interface{}) error { +func (s *readOnlySetting) Set(userID string, value any) error { return nil } @@ -64,6 +64,6 @@ func (s *readOnlySetting) GetSlackAttachments(userID, settingHandler string, dis return &sa, nil } -func (s *readOnlySetting) IsDisabled(foreignValue interface{}) bool { +func (s *readOnlySetting) IsDisabled(foreignValue any) bool { return foreignValue == FalseString } diff --git a/server/public/pluginapi/experimental/panel/settings/setting.go b/server/public/pluginapi/experimental/panel/settings/setting.go index 672ebdfd8f..c4ecc594cd 100644 --- a/server/public/pluginapi/experimental/panel/settings/setting.go +++ b/server/public/pluginapi/experimental/panel/settings/setting.go @@ -22,11 +22,11 @@ const ( // Setting defines the behavior of each element a the panel type Setting interface { - Set(userID string, value interface{}) error - Get(userID string) (interface{}, error) + Set(userID string, value any) error + Get(userID string) (any, error) GetID() string GetDependency() string - IsDisabled(foreignValue interface{}) bool + IsDisabled(foreignValue any) bool GetTitle() string GetDescription() string GetSlackAttachments(userID, settingHandler string, disabled bool) (*model.SlackAttachment, error) diff --git a/server/public/pluginapi/experimental/panel/settings/store.go b/server/public/pluginapi/experimental/panel/settings/store.go index 45afce6c74..3af349dacd 100644 --- a/server/public/pluginapi/experimental/panel/settings/store.go +++ b/server/public/pluginapi/experimental/panel/settings/store.go @@ -2,6 +2,6 @@ package settings // SettingStore defines the behavior needed to set and get settings type SettingStore interface { - SetSetting(userID, settingID string, value interface{}) error - GetSetting(userID, settingID string) (interface{}, error) + SetSetting(userID, settingID string, value any) error + GetSetting(userID, settingID string) (any, error) } diff --git a/server/public/pluginapi/experimental/telemetry/tracker.go b/server/public/pluginapi/experimental/telemetry/tracker.go index ccb16c5326..c80317594f 100644 --- a/server/public/pluginapi/experimental/telemetry/tracker.go +++ b/server/public/pluginapi/experimental/telemetry/tracker.go @@ -39,9 +39,9 @@ func NewTrackerConfig(config *model.Config) TrackerConfig { // Tracker defines a telemetry tracker type Tracker interface { // TrackEvent registers an event through the configured telemetry client - TrackEvent(event string, properties map[string]interface{}) error + TrackEvent(event string, properties map[string]any) error // TrackUserEvent registers an event through the configured telemetry client associated to a user - TrackUserEvent(event string, userID string, properties map[string]interface{}) error + TrackUserEvent(event string, userID string, properties map[string]any) error // Reload Config re-evaluates tracker config to determine if tracking behavior should change ReloadConfig(config TrackerConfig) } @@ -58,7 +58,7 @@ type Client interface { type Track struct { UserID string Event string - Properties map[string]interface{} + Properties map[string]any InstallationID string } @@ -126,14 +126,14 @@ func (t *tracker) ReloadConfig(config TrackerConfig) { } // Note that config lock is handled by the caller. -func (t *tracker) debugf(message string, args ...interface{}) { +func (t *tracker) debugf(message string, args ...any) { if t.logger == nil || !t.config.EnabledLogging { return } t.logger.Debugf(message, args...) } -func (t *tracker) TrackEvent(event string, properties map[string]interface{}) error { +func (t *tracker) TrackEvent(event string, properties map[string]any) error { t.configLock.RLock() defer t.configLock.RUnlock() @@ -144,7 +144,7 @@ func (t *tracker) TrackEvent(event string, properties map[string]interface{}) er } if properties == nil { - properties = map[string]interface{}{} + properties = map[string]any{} } properties["PluginID"] = t.pluginID properties["PluginVersion"] = t.pluginVersion @@ -169,9 +169,9 @@ func (t *tracker) TrackEvent(event string, properties map[string]interface{}) er return nil } -func (t *tracker) TrackUserEvent(event, userID string, properties map[string]interface{}) error { +func (t *tracker) TrackUserEvent(event, userID string, properties map[string]any) error { if properties == nil { - properties = map[string]interface{}{} + properties = map[string]any{} } properties["UserActualID"] = userID diff --git a/server/public/pluginapi/frontend.go b/server/public/pluginapi/frontend.go index dc94059839..a0382318c3 100644 --- a/server/public/pluginapi/frontend.go +++ b/server/public/pluginapi/frontend.go @@ -25,6 +25,6 @@ func (f *FrontendService) OpenInteractiveDialog(dialog model.OpenDialogRequest) // broadcast determines to which users to send the event. // // Minimum server version: 5.2 -func (f *FrontendService) PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) { +func (f *FrontendService) PublishWebSocketEvent(event string, payload map[string]any, broadcast *model.WebsocketBroadcast) { f.api.PublishWebSocketEvent(event, payload, broadcast) } diff --git a/server/public/pluginapi/i18n/i18n.go b/server/public/pluginapi/i18n/i18n.go index 26447c0adb..bda56d82c1 100644 --- a/server/public/pluginapi/i18n/i18n.go +++ b/server/public/pluginapi/i18n/i18n.go @@ -18,7 +18,7 @@ type PluginAPI interface { GetBundlePath() (string, error) GetConfig() *model.Config GetUser(userID string) (*model.User, *model.AppError) - LogWarn(msg string, keyValuePairs ...interface{}) + LogWarn(msg string, keyValuePairs ...any) } // Message is a string that can be localized. diff --git a/server/public/pluginapi/kv.go b/server/public/pluginapi/kv.go index ba3a0f0df1..837c8b37ec 100644 --- a/server/public/pluginapi/kv.go +++ b/server/public/pluginapi/kv.go @@ -24,7 +24,7 @@ type KVService struct { type KVSetOptions struct { model.PluginKVSetOptions - oldValue interface{} + oldValue any } // KVSetOption is an option passed to Set() operation. @@ -33,7 +33,7 @@ type KVSetOption func(*KVSetOptions) // SetAtomic guarantees the write will occur only when the current value of matches the given old // value. A client is expected to read the old value first, then pass it back to ensure the value // has not since been modified. -func SetAtomic(oldValue interface{}) KVSetOption { +func SetAtomic(oldValue any) KVSetOption { return func(o *KVSetOptions) { o.Atomic = true o.oldValue = oldValue @@ -55,7 +55,7 @@ func SetExpiry(ttl time.Duration) KVSetOption { // Returns (true, nil) if the value was set // // Minimum server version: 5.18 -func (k *KVService) Set(key string, value interface{}, options ...KVSetOption) (bool, error) { +func (k *KVService) Set(key string, value any, options ...KVSetOption) (bool, error) { if strings.HasPrefix(key, internalKeyPrefix) { return false, errors.Errorf("'%s' prefix is not allowed for keys", internalKeyPrefix) } @@ -123,7 +123,7 @@ func (k *KVService) Set(key string, value interface{}, options ...KVSetOption) ( // Returns nil if the value was set. // // Minimum server version: 5.18 -func (k *KVService) SetAtomicWithRetries(key string, valueFunc func(oldValue []byte) (newValue interface{}, err error)) error { +func (k *KVService) SetAtomicWithRetries(key string, valueFunc func(oldValue []byte) (newValue any, err error)) error { for i := 0; i < numRetries; i++ { var oldVal []byte if err := k.Get(key, &oldVal); err != nil { @@ -153,7 +153,7 @@ func (k *KVService) SetAtomicWithRetries(key string, valueFunc func(oldValue []b // error, with nothing written to the given interface. // // Minimum server version: 5.2 -func (k *KVService) Get(key string, o interface{}) error { +func (k *KVService) Get(key string, o any) error { data, appErr := k.api.KVGet(key) if appErr != nil { return normalizeAppErr(appErr) diff --git a/server/public/pluginapi/kv_test.go b/server/public/pluginapi/kv_test.go index babbc8cc0f..ddf0f32450 100644 --- a/server/public/pluginapi/kv_test.go +++ b/server/public/pluginapi/kv_test.go @@ -24,7 +24,7 @@ func TestKVSet(t *testing.T) { tests := []struct { name string key string - value interface{} + value any options []pluginapi.KVSetOption expectedValue []byte expectedOptions model.PluginKVSetOptions @@ -158,7 +158,7 @@ func TestSetAtomicWithRetries(t *testing.T) { tests := []struct { name string key string - valueFunc func(t *testing.T) func(old []byte) (interface{}, error) + valueFunc func(t *testing.T) func(old []byte) (any, error) setupAPI func(api *plugintest.API) wantErr bool expectedErrPrefix string @@ -166,8 +166,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test SetAtomicWithRetries success after first attempt", key: "testNum", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { return 2, nil } }, @@ -184,8 +184,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test success after first attempt, old is struct and as expected", key: "testNum2", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { type toStore struct { Value int } @@ -213,8 +213,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test success after first attempt, old is an int value and as expected", key: "testNum2", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { fromDB, err := strconv.Atoi(string(old)) if err != nil { return nil, err @@ -236,8 +236,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test SetAtomicWithRetries success on fourth attempt", key: "testNum", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { return 2, nil } }, @@ -258,8 +258,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test SetAtomicWithRetries success on fourth attempt because value was changed between calls to KVGet", key: "testNum", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { return 2, nil } }, @@ -280,8 +280,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test SetAtomicWithRetries failure on get", key: "testNum", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { return nil, errors.New("should not have got here") } }, @@ -294,8 +294,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test SetAtomicWithRetries failure on valueFunc", key: "testNum", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { return nil, errors.New("some user provided error") } }, @@ -309,8 +309,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test SetAtomicWithRetries DB failure on set", key: "testNum", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { return 2, nil } }, @@ -329,8 +329,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test SetAtomicWithRetries failure on five set attempts -- depends on numRetries constant being = 5", key: "testNum", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { return 2, nil } }, @@ -349,8 +349,8 @@ func TestSetAtomicWithRetries(t *testing.T) { { name: "Test SetAtomicWithRetries success after five set attempts -- depends on numRetries constant being = 5", key: "testNum", - valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) { - return func(old []byte) (interface{}, error) { + valueFunc: func(t *testing.T) func(old []byte) (any, error) { + return func(old []byte) (any, error) { fromDB, err := strconv.Atoi(string(old)) if err != nil { return nil, err diff --git a/server/public/pluginapi/log.go b/server/public/pluginapi/log.go index 34184b6602..9974021cd0 100644 --- a/server/public/pluginapi/log.go +++ b/server/public/pluginapi/log.go @@ -13,21 +13,21 @@ type LogService struct { } // Error logs an error message, optionally structured with alternating key, value parameters. -func (l *LogService) Error(message string, keyValuePairs ...interface{}) { +func (l *LogService) Error(message string, keyValuePairs ...any) { l.api.LogError(message, keyValuePairs...) } // Warn logs an error message, optionally structured with alternating key, value parameters. -func (l *LogService) Warn(message string, keyValuePairs ...interface{}) { +func (l *LogService) Warn(message string, keyValuePairs ...any) { l.api.LogWarn(message, keyValuePairs...) } // Info logs an error message, optionally structured with alternating key, value parameters. -func (l *LogService) Info(message string, keyValuePairs ...interface{}) { +func (l *LogService) Info(message string, keyValuePairs ...any) { l.api.LogInfo(message, keyValuePairs...) } // Debug logs an error message, optionally structured with alternating key, value parameters. -func (l *LogService) Debug(message string, keyValuePairs ...interface{}) { +func (l *LogService) Debug(message string, keyValuePairs ...any) { l.api.LogDebug(message, keyValuePairs...) } diff --git a/server/public/pluginapi/logrus.go b/server/public/pluginapi/logrus.go index 37999d012f..e5e65b9ab2 100644 --- a/server/public/pluginapi/logrus.go +++ b/server/public/pluginapi/logrus.go @@ -33,7 +33,7 @@ func (lh *LogrusHook) Levels() []logrus.Level { // Fire proxies logrus entries through the plugin API at the appropriate level. func (lh *LogrusHook) Fire(entry *logrus.Entry) error { - fields := []interface{}{} + fields := []any{} for key, value := range entry.Data { fields = append(fields, key, fmt.Sprintf("%+v", value)) } diff --git a/server/public/shared/request/context.go b/server/public/shared/request/context.go index 6ebd37ceb5..2458047374 100644 --- a/server/public/shared/request/context.go +++ b/server/public/shared/request/context.go @@ -151,7 +151,7 @@ func (c *Context) With(f func(ctx CTX) CTX) CTX { // CTX should be abbreviated as `rctx`. type CTX interface { - T(string, ...interface{}) string + T(string, ...any) string GetT() i18n.TranslateFunc Session() *model.Session RequestId() string diff --git a/server/public/utils/json_test.go b/server/public/utils/json_test.go index 95ecdcc815..41cec65601 100644 --- a/server/public/utils/json_test.go +++ b/server/public/utils/json_test.go @@ -296,7 +296,7 @@ func TestIsJSONEmpty(t *testing.T) { if !testCase.Empty { // don't really need to test the JSON unmarshaller but this is included // to ensure the test cases stay valid. - var v interface{} + var v any err := json.Unmarshal(testCase.Data, &v) assert.NoError(t, err) } diff --git a/tools/mmgotool/commands/i18n.go b/tools/mmgotool/commands/i18n.go index 5e7c12d767..760ddd305f 100644 --- a/tools/mmgotool/commands/i18n.go +++ b/tools/mmgotool/commands/i18n.go @@ -26,8 +26,8 @@ const enterpriseKeyPrefix = "ent." const untranslatedKey = "" type Translation struct { - Id string `json:"id"` - Translation interface{} `json:"translation"` + Id string `json:"id"` + Translation any `json:"translation"` } type Item struct { @@ -730,7 +730,7 @@ func removeEmptyTranslations(oldList []Item) ([]Item, int) { return newList, count } -func JSONMarshal(t interface{}) ([]byte, error) { +func JSONMarshal(t any) ([]byte, error) { buffer := &bytes.Buffer{} encoder := json.NewEncoder(buffer) encoder.SetEscapeHTML(false)