Skip to content

Commit f8d693f

Browse files
committed
feat: rewrite interface{} to any
Signed-off-by: Gaius <[email protected]>
1 parent 6955e7c commit f8d693f

File tree

126 files changed

+1003
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1003
-1003
lines changed

client/clientutil/mocks/keepalive_mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/clientutil/types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func (r *RateLimit) UnmarshalYAML(node *yaml.Node) error {
4444
return r.unmarshal(yaml.Unmarshal, []byte(node.Value))
4545
}
4646

47-
func (r *RateLimit) unmarshal(unmarshal func(in []byte, out interface{}) (err error), b []byte) error {
48-
var v interface{}
47+
func (r *RateLimit) unmarshal(unmarshal func(in []byte, out any) (err error), b []byte) error {
48+
var v any
4949
if err := unmarshal(b, &v); err != nil {
5050
return err
5151
}
@@ -73,15 +73,15 @@ type Duration struct {
7373
}
7474

7575
func (d *Duration) UnmarshalJSON(b []byte) error {
76-
var v interface{}
76+
var v any
7777
if err := json.Unmarshal(b, &v); err != nil {
7878
return err
7979
}
8080
return d.unmarshal(v)
8181
}
8282

8383
func (d *Duration) UnmarshalYAML(node *yaml.Node) error {
84-
var v interface{}
84+
var v any
8585
switch node.Kind {
8686
case yaml.ScalarNode:
8787
switch node.Tag {
@@ -106,7 +106,7 @@ func (d *Duration) UnmarshalYAML(node *yaml.Node) error {
106106
return d.unmarshal(v)
107107
}
108108

109-
func (d *Duration) unmarshal(v interface{}) error {
109+
func (d *Duration) unmarshal(v any) error {
110110
switch value := v.(type) {
111111
case float64:
112112
d.Duration = time.Duration(value)

client/config/dynconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func newManagerClient(client managerclient.Client, hostOption HostOption) intern
212212
}
213213
}
214214

215-
func (mc *managerClient) Get() (interface{}, error) {
215+
func (mc *managerClient) Get() (any, error) {
216216
listSchedulersResp, err := mc.ListSchedulers(&manager.ListSchedulersRequest{
217217
SourceType: manager.SourceType_PEER_SOURCE,
218218
HostName: mc.hostOption.Hostname,

client/config/mocks/dynconfig_mock.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/config/peerhost.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ type ProxyOption struct {
263263
}
264264

265265
func (p *ProxyOption) UnmarshalJSON(b []byte) error {
266-
var v interface{}
266+
var v any
267267
if err := json.Unmarshal(b, &v); err != nil {
268268
return err
269269
}
@@ -278,7 +278,7 @@ func (p *ProxyOption) UnmarshalJSON(b []byte) error {
278278
return err
279279
}
280280
return nil
281-
case map[string]interface{}:
281+
case map[string]any:
282282
if err := p.unmarshal(json.Unmarshal, b); err != nil {
283283
return err
284284
}
@@ -305,11 +305,11 @@ func (p *ProxyOption) UnmarshalYAML(node *yaml.Node) error {
305305
}
306306
return nil
307307
case yaml.MappingNode:
308-
var m = make(map[string]interface{})
308+
var m = make(map[string]any)
309309
for i := 0; i < len(node.Content); i += 2 {
310310
var (
311311
key string
312-
value interface{}
312+
value any
313313
)
314314
if err := node.Content[i].Decode(&key); err != nil {
315315
return err
@@ -334,7 +334,7 @@ func (p *ProxyOption) UnmarshalYAML(node *yaml.Node) error {
334334
}
335335
}
336336

337-
func (p *ProxyOption) unmarshal(unmarshal func(in []byte, out interface{}) (err error), b []byte) error {
337+
func (p *ProxyOption) unmarshal(unmarshal func(in []byte, out any) (err error), b []byte) error {
338338
pt := struct {
339339
ListenOption `mapstructure:",squash" yaml:",inline"`
340340
BasicAuth *BasicAuth `mapstructure:"basicAuth" yaml:"basicAuth"`
@@ -412,18 +412,18 @@ type TCPListenPortRange struct {
412412
}
413413

414414
func (t *TCPListenPortRange) UnmarshalJSON(b []byte) error {
415-
var v interface{}
415+
var v any
416416
if err := json.Unmarshal(b, &v); err != nil {
417417
return err
418418
}
419419
return t.unmarshal(v)
420420
}
421421

422422
func (t *TCPListenPortRange) UnmarshalYAML(node *yaml.Node) error {
423-
var v interface{}
423+
var v any
424424
switch node.Kind {
425425
case yaml.MappingNode:
426-
var m = make(map[string]interface{})
426+
var m = make(map[string]any)
427427
for i := 0; i < len(node.Content); i += 2 {
428428
var (
429429
key string
@@ -448,15 +448,15 @@ func (t *TCPListenPortRange) UnmarshalYAML(node *yaml.Node) error {
448448
return t.unmarshal(v)
449449
}
450450

451-
func (t *TCPListenPortRange) unmarshal(v interface{}) error {
451+
func (t *TCPListenPortRange) unmarshal(v any) error {
452452
switch value := v.(type) {
453453
case int:
454454
t.Start = value
455455
return nil
456456
case float64:
457457
t.Start = int(value)
458458
return nil
459-
case map[string]interface{}:
459+
case map[string]any:
460460
if s, ok := value["start"]; ok {
461461
switch start := s.(type) {
462462
case float64:
@@ -638,11 +638,11 @@ type URL struct {
638638

639639
// UnmarshalJSON implements json.Unmarshaler.
640640
func (u *URL) UnmarshalJSON(b []byte) error {
641-
return u.unmarshal(func(v interface{}) error { return json.Unmarshal(b, v) })
641+
return u.unmarshal(func(v any) error { return json.Unmarshal(b, v) })
642642
}
643643

644644
// UnmarshalYAML implements yaml.Unmarshaler.
645-
func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
645+
func (u *URL) UnmarshalYAML(unmarshal func(any) error) error {
646646
return u.unmarshal(unmarshal)
647647
}
648648

@@ -652,11 +652,11 @@ func (u *URL) MarshalJSON() ([]byte, error) {
652652
}
653653

654654
// MarshalYAML implements yaml.Marshaller to print the url.
655-
func (u *URL) MarshalYAML() (interface{}, error) {
655+
func (u *URL) MarshalYAML() (any, error) {
656656
return u.String(), nil
657657
}
658658

659-
func (u *URL) unmarshal(unmarshal func(interface{}) error) error {
659+
func (u *URL) unmarshal(unmarshal func(any) error) error {
660660
var s string
661661
if err := unmarshal(&s); err != nil {
662662
return err
@@ -680,11 +680,11 @@ type CertPool struct {
680680

681681
// UnmarshalJSON implements json.Unmarshaler.
682682
func (cp *CertPool) UnmarshalJSON(b []byte) error {
683-
return cp.unmarshal(func(v interface{}) error { return json.Unmarshal(b, v) })
683+
return cp.unmarshal(func(v any) error { return json.Unmarshal(b, v) })
684684
}
685685

686686
// UnmarshalYAML implements yaml.Unmarshaler.
687-
func (cp *CertPool) UnmarshalYAML(unmarshal func(interface{}) error) error {
687+
func (cp *CertPool) UnmarshalYAML(unmarshal func(any) error) error {
688688
return cp.unmarshal(unmarshal)
689689
}
690690

@@ -694,11 +694,11 @@ func (cp *CertPool) MarshalJSON() ([]byte, error) {
694694
}
695695

696696
// MarshalYAML implements yaml.Marshaller to print the cert pool.
697-
func (cp *CertPool) MarshalYAML() (interface{}, error) {
697+
func (cp *CertPool) MarshalYAML() (any, error) {
698698
return cp.Files, nil
699699
}
700700

701-
func (cp *CertPool) unmarshal(unmarshal func(interface{}) error) error {
701+
func (cp *CertPool) unmarshal(unmarshal func(any) error) error {
702702
if err := unmarshal(&cp.Files); err != nil {
703703
return err
704704
}
@@ -776,16 +776,16 @@ func NewRegexp(exp string) (*Regexp, error) {
776776
}
777777

778778
// UnmarshalYAML implements yaml.Unmarshaler.
779-
func (r *Regexp) UnmarshalYAML(unmarshal func(interface{}) error) error {
779+
func (r *Regexp) UnmarshalYAML(unmarshal func(any) error) error {
780780
return r.unmarshal(unmarshal)
781781
}
782782

783783
// UnmarshalJSON implements json.Unmarshaler.
784784
func (r *Regexp) UnmarshalJSON(b []byte) error {
785-
return r.unmarshal(func(v interface{}) error { return json.Unmarshal(b, v) })
785+
return r.unmarshal(func(v any) error { return json.Unmarshal(b, v) })
786786
}
787787

788-
func (r *Regexp) unmarshal(unmarshal func(interface{}) error) error {
788+
func (r *Regexp) unmarshal(unmarshal func(any) error) error {
789789
var s string
790790
if err := unmarshal(&s); err != nil {
791791
return err
@@ -803,7 +803,7 @@ func (r *Regexp) MarshalJSON() ([]byte, error) {
803803
}
804804

805805
// MarshalYAML implements yaml.Marshaller to print the regexp.
806-
func (r *Regexp) MarshalYAML() (interface{}, error) {
806+
func (r *Regexp) MarshalYAML() (any, error) {
807807
return r.String(), nil
808808
}
809809

client/config/peerhost_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Test_AllUnmarshalYAML(t *testing.T) {
3535
assert := testifyassert.New(t)
3636
var cases = []struct {
3737
text string
38-
target interface{}
38+
target any
3939
}{
4040
{
4141
text: `

client/daemon/objectstorage/mocks/objectstorage_mock.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/daemon/peer/peertask_manager_mock.go

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)