Skip to content

Commit c5e653c

Browse files
committed
Refactor variadic parameter type to 'any'
Changed variadic parameter type from 'interface{}' to 'any' in logger and debugger functions for improved Go 1.18+ compatibility and clarity.
1 parent 9df7ab7 commit c5e653c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

mega.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ type Mega struct {
124124
// HTTP Client
125125
client *http.Client
126126
// Loggers
127-
logf func(format string, v ...interface{})
128-
debugf func(format string, v ...interface{})
127+
logf func(format string, v ...any)
128+
debugf func(format string, v ...any)
129129
// serialize the API requests
130130
apiMu sync.Mutex
131131
// mutex to protext waitEvents
@@ -369,7 +369,7 @@ func (m *Mega) SetClient(client *http.Client) *Mega {
369369
}
370370

371371
// discardLogf discards the log messages
372-
func discardLogf(format string, v ...interface{}) {
372+
func discardLogf(format string, v ...any) {
373373
}
374374

375375
// Returns an opaque string representing the session
@@ -391,7 +391,7 @@ func (m *Mega) LoginWithKeys(sessionId string, masterKey []byte) error {
391391

392392
// SetLogger sets the logger for important messages. By default this
393393
// is log.Printf. Use nil to discard the messages.
394-
func (m *Mega) SetLogger(logf func(format string, v ...interface{})) *Mega {
394+
func (m *Mega) SetLogger(logf func(format string, v ...any)) *Mega {
395395
if logf == nil {
396396
logf = discardLogf
397397
}
@@ -401,7 +401,7 @@ func (m *Mega) SetLogger(logf func(format string, v ...interface{})) *Mega {
401401

402402
// SetDebugger sets the logger for debug messages. By default these
403403
// messages are not output.
404-
func (m *Mega) SetDebugger(debugf func(format string, v ...interface{})) *Mega {
404+
func (m *Mega) SetDebugger(debugf func(format string, v ...any)) *Mega {
405405
if debugf == nil {
406406
debugf = discardLogf
407407
}

test_tools/test_real_api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func main() {
1919
m := mega.New()
2020

2121
// Enable debug logging to see the hashcash flow if it happens
22-
m.SetDebugger(func(format string, v ...interface{}) {
22+
m.SetDebugger(func(format string, v ...any) {
2323
log.Printf("[DEBUG] "+format, v...)
2424
})
2525

26-
m.SetLogger(func(format string, v ...interface{}) {
26+
m.SetLogger(func(format string, v ...any) {
2727
log.Printf("[INFO] "+format, v...)
2828
})
2929

0 commit comments

Comments
 (0)