Enforce use of any instead of interface{} (#30588)

This commit is contained in:
Ben Schumacher 2025-03-31 10:44:34 +02:00 committed by GitHub
parent 9aa4818c71
commit 166a676fe5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
78 changed files with 268 additions and 262 deletions

View file

@ -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: "\

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,5 +4,4 @@
package missing
// SomeType is a fake interface for testing the plugin comment checker.
type SomeType interface {
}
type SomeType any

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -26,8 +26,8 @@ const enterpriseKeyPrefix = "ent."
const untranslatedKey = "<untranslated>"
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)