Skip to content

Commit d563660

Browse files
authored
Merge pull request #4515 from heliapb/feat/am_any
fix: replace `interface{}` with any
2 parents 319103e + e75b081 commit d563660

File tree

17 files changed

+71
-71
lines changed

17 files changed

+71
-71
lines changed

cluster/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,11 @@ func (p *Peer) Status() string {
610610

611611
// Info returns a JSON-serializable dump of cluster state.
612612
// Useful for debug.
613-
func (p *Peer) Info() map[string]interface{} {
613+
func (p *Peer) Info() map[string]any {
614614
p.mtx.RLock()
615615
defer p.mtx.RUnlock()
616616

617-
return map[string]interface{}{
617+
return map[string]any{
618618
"self": p.mlist.LocalNode(),
619619
"members": p.mlist.Members(),
620620
}

cmd/alertmanager/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func run() int {
218218
}
219219

220220
if ff.EnableAutoGOMAXPROCS() {
221-
l := func(format string, a ...interface{}) {
221+
l := func(format string, a ...any) {
222222
logger.Info("automaxprocs", "msg", fmt.Sprintf(strings.TrimPrefix(format, "maxprocs: "), a...))
223223
}
224224
if _, err := maxprocs.Set(maxprocs.Logger(l)); err != nil {

config/config.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func init() {
5656
type Secret string
5757

5858
// MarshalYAML implements the yaml.Marshaler interface for Secret.
59-
func (s Secret) MarshalYAML() (interface{}, error) {
59+
func (s Secret) MarshalYAML() (any, error) {
6060
if MarshalSecretValue {
6161
return string(s), nil
6262
}
@@ -67,7 +67,7 @@ func (s Secret) MarshalYAML() (interface{}, error) {
6767
}
6868

6969
// UnmarshalYAML implements the yaml.Unmarshaler interface for Secret.
70-
func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error {
70+
func (s *Secret) UnmarshalYAML(unmarshal func(any) error) error {
7171
type plain Secret
7272
return unmarshal((*plain)(s))
7373
}
@@ -95,15 +95,15 @@ func (u *URL) Copy() *URL {
9595
}
9696

9797
// MarshalYAML implements the yaml.Marshaler interface for URL.
98-
func (u URL) MarshalYAML() (interface{}, error) {
98+
func (u URL) MarshalYAML() (any, error) {
9999
if u.URL != nil {
100100
return u.String(), nil
101101
}
102102
return nil, nil
103103
}
104104

105105
// UnmarshalYAML implements the yaml.Unmarshaler interface for URL.
106-
func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
106+
func (u *URL) UnmarshalYAML(unmarshal func(any) error) error {
107107
var s string
108108
if err := unmarshal(&s); err != nil {
109109
return err
@@ -142,7 +142,7 @@ func (u *URL) UnmarshalJSON(data []byte) error {
142142
type SecretURL URL
143143

144144
// MarshalYAML implements the yaml.Marshaler interface for SecretURL.
145-
func (s SecretURL) MarshalYAML() (interface{}, error) {
145+
func (s SecretURL) MarshalYAML() (any, error) {
146146
if s.URL != nil {
147147
if MarshalSecretValue {
148148
return s.String(), nil
@@ -153,7 +153,7 @@ func (s SecretURL) MarshalYAML() (interface{}, error) {
153153
}
154154

155155
// UnmarshalYAML implements the yaml.Unmarshaler interface for SecretURL.
156-
func (s *SecretURL) UnmarshalYAML(unmarshal func(interface{}) error) error {
156+
func (s *SecretURL) UnmarshalYAML(unmarshal func(any) error) error {
157157
var str string
158158
if err := unmarshal(&str); err != nil {
159159
return err
@@ -308,7 +308,7 @@ type MuteTimeInterval struct {
308308
}
309309

310310
// UnmarshalYAML implements the yaml.Unmarshaler interface for MuteTimeInterval.
311-
func (mt *MuteTimeInterval) UnmarshalYAML(unmarshal func(interface{}) error) error {
311+
func (mt *MuteTimeInterval) UnmarshalYAML(unmarshal func(any) error) error {
312312
type plain MuteTimeInterval
313313
if err := unmarshal((*plain)(mt)); err != nil {
314314
return err
@@ -326,7 +326,7 @@ type TimeInterval struct {
326326
}
327327

328328
// UnmarshalYAML implements the yaml.Unmarshaler interface for MuteTimeInterval.
329-
func (ti *TimeInterval) UnmarshalYAML(unmarshal func(interface{}) error) error {
329+
func (ti *TimeInterval) UnmarshalYAML(unmarshal func(any) error) error {
330330
type plain TimeInterval
331331
if err := unmarshal((*plain)(ti)); err != nil {
332332
return err
@@ -361,7 +361,7 @@ func (c Config) String() string {
361361
}
362362

363363
// UnmarshalYAML implements the yaml.Unmarshaler interface for Config.
364-
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
364+
func (c *Config) UnmarshalYAML(unmarshal func(any) error) error {
365365
// We want to set c to the defaults and then overwrite it with the input.
366366
// To make unmarshal fill the plain data struct rather than calling UnmarshalYAML
367367
// again, we have to hide it using a type indirection.
@@ -768,7 +768,7 @@ type HostPort struct {
768768
}
769769

770770
// UnmarshalYAML implements the yaml.Unmarshaler interface for HostPort.
771-
func (hp *HostPort) UnmarshalYAML(unmarshal func(interface{}) error) error {
771+
func (hp *HostPort) UnmarshalYAML(unmarshal func(any) error) error {
772772
var (
773773
s string
774774
err error
@@ -812,7 +812,7 @@ func (hp *HostPort) UnmarshalJSON(data []byte) error {
812812
}
813813

814814
// MarshalYAML implements the yaml.Marshaler interface for HostPort.
815-
func (hp HostPort) MarshalYAML() (interface{}, error) {
815+
func (hp HostPort) MarshalYAML() (any, error) {
816816
return hp.String(), nil
817817
}
818818

@@ -870,7 +870,7 @@ type GlobalConfig struct {
870870
}
871871

872872
// UnmarshalYAML implements the yaml.Unmarshaler interface for GlobalConfig.
873-
func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
873+
func (c *GlobalConfig) UnmarshalYAML(unmarshal func(any) error) error {
874874
*c = DefaultGlobalConfig()
875875
type plain GlobalConfig
876876
return unmarshal((*plain)(c))
@@ -899,7 +899,7 @@ type Route struct {
899899
}
900900

901901
// UnmarshalYAML implements the yaml.Unmarshaler interface for Route.
902-
func (r *Route) UnmarshalYAML(unmarshal func(interface{}) error) error {
902+
func (r *Route) UnmarshalYAML(unmarshal func(any) error) error {
903903
type plain Route
904904
if err := unmarshal((*plain)(r)); err != nil {
905905
return err
@@ -972,7 +972,7 @@ type InhibitRule struct {
972972
}
973973

974974
// UnmarshalYAML implements the yaml.Unmarshaler interface for InhibitRule.
975-
func (r *InhibitRule) UnmarshalYAML(unmarshal func(interface{}) error) error {
975+
func (r *InhibitRule) UnmarshalYAML(unmarshal func(any) error) error {
976976
type plain InhibitRule
977977
if err := unmarshal((*plain)(r)); err != nil {
978978
return err
@@ -1024,7 +1024,7 @@ type Receiver struct {
10241024
}
10251025

10261026
// UnmarshalYAML implements the yaml.Unmarshaler interface for Receiver.
1027-
func (c *Receiver) UnmarshalYAML(unmarshal func(interface{}) error) error {
1027+
func (c *Receiver) UnmarshalYAML(unmarshal func(any) error) error {
10281028
type plain Receiver
10291029
if err := unmarshal((*plain)(c)); err != nil {
10301030
return err
@@ -1039,7 +1039,7 @@ func (c *Receiver) UnmarshalYAML(unmarshal func(interface{}) error) error {
10391039
type MatchRegexps map[string]Regexp
10401040

10411041
// UnmarshalYAML implements the yaml.Unmarshaler interface for MatchRegexps.
1042-
func (m *MatchRegexps) UnmarshalYAML(unmarshal func(interface{}) error) error {
1042+
func (m *MatchRegexps) UnmarshalYAML(unmarshal func(any) error) error {
10431043
type plain MatchRegexps
10441044
if err := unmarshal((*plain)(m)); err != nil {
10451045
return err
@@ -1062,7 +1062,7 @@ type Regexp struct {
10621062
}
10631063

10641064
// UnmarshalYAML implements the yaml.Unmarshaler interface for Regexp.
1065-
func (re *Regexp) UnmarshalYAML(unmarshal func(interface{}) error) error {
1065+
func (re *Regexp) UnmarshalYAML(unmarshal func(any) error) error {
10661066
var s string
10671067
if err := unmarshal(&s); err != nil {
10681068
return err
@@ -1077,7 +1077,7 @@ func (re *Regexp) UnmarshalYAML(unmarshal func(interface{}) error) error {
10771077
}
10781078

10791079
// MarshalYAML implements the yaml.Marshaler interface for Regexp.
1080-
func (re Regexp) MarshalYAML() (interface{}, error) {
1080+
func (re Regexp) MarshalYAML() (any, error) {
10811081
if re.original != "" {
10821082
return re.original, nil
10831083
}
@@ -1112,7 +1112,7 @@ func (re Regexp) MarshalJSON() ([]byte, error) {
11121112
type Matchers labels.Matchers
11131113

11141114
// UnmarshalYAML implements the yaml.Unmarshaler interface for Matchers.
1115-
func (m *Matchers) UnmarshalYAML(unmarshal func(interface{}) error) error {
1115+
func (m *Matchers) UnmarshalYAML(unmarshal func(any) error) error {
11161116
var lines []string
11171117
if err := unmarshal(&lines); err != nil {
11181118
return err
@@ -1129,7 +1129,7 @@ func (m *Matchers) UnmarshalYAML(unmarshal func(interface{}) error) error {
11291129
}
11301130

11311131
// MarshalYAML implements the yaml.Marshaler interface for Matchers.
1132-
func (m Matchers) MarshalYAML() (interface{}, error) {
1132+
func (m Matchers) MarshalYAML() (any, error) {
11331133
result := make([]string, len(m))
11341134
for i, matcher := range m {
11351135
result[i] = matcher.String()

config/notifiers.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ type WebexConfig struct {
225225
}
226226

227227
// UnmarshalYAML implements the yaml.Unmarshaler interface.
228-
func (c *WebexConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
228+
func (c *WebexConfig) UnmarshalYAML(unmarshal func(any) error) error {
229229
*c = DefaultWebexConfig
230230
type plain WebexConfig
231231
if err := unmarshal((*plain)(c)); err != nil {
@@ -259,7 +259,7 @@ type DiscordConfig struct {
259259
}
260260

261261
// UnmarshalYAML implements the yaml.Unmarshaler interface.
262-
func (c *DiscordConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
262+
func (c *DiscordConfig) UnmarshalYAML(unmarshal func(any) error) error {
263263
*c = DefaultDiscordConfig
264264
type plain DiscordConfig
265265
if err := unmarshal((*plain)(c)); err != nil {
@@ -299,7 +299,7 @@ type EmailConfig struct {
299299
}
300300

301301
// UnmarshalYAML implements the yaml.Unmarshaler interface.
302-
func (c *EmailConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
302+
func (c *EmailConfig) UnmarshalYAML(unmarshal func(any) error) error {
303303
*c = DefaultEmailConfig
304304
type plain EmailConfig
305305
if err := unmarshal((*plain)(c)); err != nil {
@@ -360,7 +360,7 @@ type PagerdutyImage struct {
360360
}
361361

362362
// UnmarshalYAML implements the yaml.Unmarshaler interface.
363-
func (c *PagerdutyConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
363+
func (c *PagerdutyConfig) UnmarshalYAML(unmarshal func(any) error) error {
364364
*c = DefaultPagerdutyConfig
365365
type plain PagerdutyConfig
366366
if err := unmarshal((*plain)(c)); err != nil {
@@ -403,7 +403,7 @@ type SlackAction struct {
403403
}
404404

405405
// UnmarshalYAML implements the yaml.Unmarshaler interface for SlackAction.
406-
func (c *SlackAction) UnmarshalYAML(unmarshal func(interface{}) error) error {
406+
func (c *SlackAction) UnmarshalYAML(unmarshal func(any) error) error {
407407
type plain SlackAction
408408
if err := unmarshal((*plain)(c)); err != nil {
409409
return err
@@ -438,7 +438,7 @@ type SlackConfirmationField struct {
438438
}
439439

440440
// UnmarshalYAML implements the yaml.Unmarshaler interface for SlackConfirmationField.
441-
func (c *SlackConfirmationField) UnmarshalYAML(unmarshal func(interface{}) error) error {
441+
func (c *SlackConfirmationField) UnmarshalYAML(unmarshal func(any) error) error {
442442
type plain SlackConfirmationField
443443
if err := unmarshal((*plain)(c)); err != nil {
444444
return err
@@ -460,7 +460,7 @@ type SlackField struct {
460460
}
461461

462462
// UnmarshalYAML implements the yaml.Unmarshaler interface for SlackField.
463-
func (c *SlackField) UnmarshalYAML(unmarshal func(interface{}) error) error {
463+
func (c *SlackField) UnmarshalYAML(unmarshal func(any) error) error {
464464
type plain SlackField
465465
if err := unmarshal((*plain)(c)); err != nil {
466466
return err
@@ -507,7 +507,7 @@ type SlackConfig struct {
507507
}
508508

509509
// UnmarshalYAML implements the yaml.Unmarshaler interface.
510-
func (c *SlackConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
510+
func (c *SlackConfig) UnmarshalYAML(unmarshal func(any) error) error {
511511
*c = DefaultSlackConfig
512512
type plain SlackConfig
513513
if err := unmarshal((*plain)(c)); err != nil {
@@ -542,7 +542,7 @@ type WebhookConfig struct {
542542
}
543543

544544
// UnmarshalYAML implements the yaml.Unmarshaler interface.
545-
func (c *WebhookConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
545+
func (c *WebhookConfig) UnmarshalYAML(unmarshal func(any) error) error {
546546
*c = DefaultWebhookConfig
547547
type plain WebhookConfig
548548
if err := unmarshal((*plain)(c)); err != nil {
@@ -579,7 +579,7 @@ const wechatValidTypesRe = `^(text|markdown)$`
579579
var wechatTypeMatcher = regexp.MustCompile(wechatValidTypesRe)
580580

581581
// UnmarshalYAML implements the yaml.Unmarshaler interface.
582-
func (c *WechatConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
582+
func (c *WechatConfig) UnmarshalYAML(unmarshal func(any) error) error {
583583
*c = DefaultWechatConfig
584584
type plain WechatConfig
585585
if err := unmarshal((*plain)(c)); err != nil {
@@ -624,7 +624,7 @@ const opsgenieValidTypesRe = `^(team|teams|user|escalation|schedule)$`
624624
var opsgenieTypeMatcher = regexp.MustCompile(opsgenieValidTypesRe)
625625

626626
// UnmarshalYAML implements the yaml.Unmarshaler interface.
627-
func (c *OpsGenieConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
627+
func (c *OpsGenieConfig) UnmarshalYAML(unmarshal func(any) error) error {
628628
*c = DefaultOpsGenieConfig
629629
type plain OpsGenieConfig
630630
if err := unmarshal((*plain)(c)); err != nil {
@@ -684,7 +684,7 @@ type VictorOpsConfig struct {
684684
}
685685

686686
// UnmarshalYAML implements the yaml.Unmarshaler interface.
687-
func (c *VictorOpsConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
687+
func (c *VictorOpsConfig) UnmarshalYAML(unmarshal func(any) error) error {
688688
*c = DefaultVictorOpsConfig
689689
type plain VictorOpsConfig
690690
if err := unmarshal((*plain)(c)); err != nil {
@@ -746,7 +746,7 @@ type PushoverConfig struct {
746746
}
747747

748748
// UnmarshalYAML implements the yaml.Unmarshaler interface.
749-
func (c *PushoverConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
749+
func (c *PushoverConfig) UnmarshalYAML(unmarshal func(any) error) error {
750750
*c = DefaultPushoverConfig
751751
type plain PushoverConfig
752752
if err := unmarshal((*plain)(c)); err != nil {
@@ -786,7 +786,7 @@ type SNSConfig struct {
786786
}
787787

788788
// UnmarshalYAML implements the yaml.Unmarshaler interface.
789-
func (c *SNSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
789+
func (c *SNSConfig) UnmarshalYAML(unmarshal func(any) error) error {
790790
*c = DefaultSNSConfig
791791
type plain SNSConfig
792792
if err := unmarshal((*plain)(c)); err != nil {
@@ -815,7 +815,7 @@ type TelegramConfig struct {
815815
}
816816

817817
// UnmarshalYAML implements the yaml.Unmarshaler interface.
818-
func (c *TelegramConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
818+
func (c *TelegramConfig) UnmarshalYAML(unmarshal func(any) error) error {
819819
*c = DefaultTelegramConfig
820820
type plain TelegramConfig
821821
if err := unmarshal((*plain)(c)); err != nil {
@@ -850,7 +850,7 @@ type MSTeamsConfig struct {
850850
Text string `yaml:"text,omitempty" json:"text,omitempty"`
851851
}
852852

853-
func (c *MSTeamsConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
853+
func (c *MSTeamsConfig) UnmarshalYAML(unmarshal func(any) error) error {
854854
*c = DefaultMSTeamsConfig
855855
type plain MSTeamsConfig
856856
if err := unmarshal((*plain)(c)); err != nil {
@@ -878,7 +878,7 @@ type MSTeamsV2Config struct {
878878
Text string `yaml:"text,omitempty" json:"text,omitempty"`
879879
}
880880

881-
func (c *MSTeamsV2Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
881+
func (c *MSTeamsV2Config) UnmarshalYAML(unmarshal func(any) error) error {
882882
*c = DefaultMSTeamsV2Config
883883
type plain MSTeamsV2Config
884884
if err := unmarshal((*plain)(c)); err != nil {
@@ -917,7 +917,7 @@ type JiraConfig struct {
917917
Fields map[string]any `yaml:"fields,omitempty" json:"custom_fields,omitempty"`
918918
}
919919

920-
func (c *JiraConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
920+
func (c *JiraConfig) UnmarshalYAML(unmarshal func(any) error) error {
921921
*c = DefaultJiraConfig
922922
type plain JiraConfig
923923
if err := unmarshal((*plain)(c)); err != nil {
@@ -986,7 +986,7 @@ type RocketchatConfig struct {
986986
}
987987

988988
// UnmarshalYAML implements the yaml.Unmarshaler interface.
989-
func (c *RocketchatConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
989+
func (c *RocketchatConfig) UnmarshalYAML(unmarshal func(any) error) error {
990990
*c = DefaultRocketchatConfig
991991
type plain RocketchatConfig
992992
if err := unmarshal((*plain)(c)); err != nil {

notify/discord/discord_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestDiscordRetry(t *testing.T) {
5858
func TestDiscordTemplating(t *testing.T) {
5959
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
6060
dec := json.NewDecoder(r.Body)
61-
out := make(map[string]interface{})
61+
out := make(map[string]any)
6262
err := dec.Decode(&out)
6363
if err != nil {
6464
panic(err)

notify/email/email_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type mailDev struct {
8080
*url.URL
8181
}
8282

83-
func (m *mailDev) UnmarshalYAML(unmarshal func(interface{}) error) error {
83+
func (m *mailDev) UnmarshalYAML(unmarshal func(any) error) error {
8484
var s string
8585
if err := unmarshal(&s); err != nil {
8686
return err

0 commit comments

Comments
 (0)