Enforce use of any instead of interface{} (#30588)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9aa4818c71
Коммит
166a676fe5
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user