mirror of
https://github.com/pion/ice.git
synced 2025-09-26 19:41:11 +08:00
Replace interface{} with any type alias
This change maintains full backward compatibility while adopting modern Go type alias conventions for better code clarity. Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
This commit is contained in:
@@ -206,7 +206,7 @@ func TestActiveTCP_NonBlocking(t *testing.T) {
|
||||
require.NoError(t, bAgent.Close())
|
||||
}()
|
||||
|
||||
isConnected := make(chan interface{})
|
||||
isConnected := make(chan any)
|
||||
err = aAgent.OnConnectionStateChange(func(c ConnectionState) {
|
||||
if c == ConnectionStateConnected {
|
||||
close(isConnected)
|
||||
@@ -269,7 +269,7 @@ func TestActiveTCP_Respect_NetworkTypes(t *testing.T) {
|
||||
require.NoError(t, bAgent.Close())
|
||||
}()
|
||||
|
||||
isConnected := make(chan interface{})
|
||||
isConnected := make(chan any)
|
||||
err = aAgent.OnConnectionStateChange(func(c ConnectionState) {
|
||||
if c == ConnectionStateConnected {
|
||||
close(isConnected)
|
||||
|
@@ -505,7 +505,7 @@ func TestConnectionStateCallback(t *testing.T) { //nolint:cyclop
|
||||
InterfaceFilter: problematicNetworkInterfaces,
|
||||
}
|
||||
|
||||
isClosed := make(chan interface{})
|
||||
isClosed := make(chan any)
|
||||
|
||||
aAgent, err := NewAgent(cfg)
|
||||
require.NoError(t, err)
|
||||
@@ -529,10 +529,10 @@ func TestConnectionStateCallback(t *testing.T) { //nolint:cyclop
|
||||
require.NoError(t, bAgent.Close())
|
||||
}()
|
||||
|
||||
isChecking := make(chan interface{})
|
||||
isConnected := make(chan interface{})
|
||||
isDisconnected := make(chan interface{})
|
||||
isFailed := make(chan interface{})
|
||||
isChecking := make(chan any)
|
||||
isConnected := make(chan any)
|
||||
isDisconnected := make(chan any)
|
||||
isFailed := make(chan any)
|
||||
err = aAgent.OnConnectionStateChange(func(c ConnectionState) {
|
||||
switch c {
|
||||
case ConnectionStateChecking:
|
||||
@@ -1058,7 +1058,7 @@ func TestConnectionStateFailedDeleteAllCandidates(t *testing.T) {
|
||||
require.NoError(t, bAgent.Close())
|
||||
}()
|
||||
|
||||
isFailed := make(chan interface{})
|
||||
isFailed := make(chan any)
|
||||
require.NoError(t, aAgent.OnConnectionStateChange(func(c ConnectionState) {
|
||||
if c == ConnectionStateFailed {
|
||||
close(isFailed)
|
||||
@@ -1364,8 +1364,8 @@ func TestCloseInConnectionStateCallback(t *testing.T) {
|
||||
require.NoError(t, bAgent.Close())
|
||||
}()
|
||||
|
||||
isClosed := make(chan interface{})
|
||||
isConnected := make(chan interface{})
|
||||
isClosed := make(chan any)
|
||||
isConnected := make(chan any)
|
||||
err = aAgent.OnConnectionStateChange(func(c ConnectionState) {
|
||||
switch c {
|
||||
case ConnectionStateConnected:
|
||||
@@ -1414,7 +1414,7 @@ func TestRunTaskInConnectionStateCallback(t *testing.T) {
|
||||
require.NoError(t, bAgent.Close())
|
||||
}()
|
||||
|
||||
isComplete := make(chan interface{})
|
||||
isComplete := make(chan any)
|
||||
err = aAgent.OnConnectionStateChange(func(c ConnectionState) {
|
||||
if c == ConnectionStateConnected {
|
||||
_, _, errCred := aAgent.GetLocalUserCredentials()
|
||||
@@ -1459,8 +1459,8 @@ func TestRunTaskInSelectedCandidatePairChangeCallback(t *testing.T) {
|
||||
require.NoError(t, bAgent.Close())
|
||||
}()
|
||||
|
||||
isComplete := make(chan interface{})
|
||||
isTested := make(chan interface{})
|
||||
isComplete := make(chan any)
|
||||
isTested := make(chan any)
|
||||
err = aAgent.OnSelectedCandidatePairChange(func(Candidate, Candidate) {
|
||||
go func() {
|
||||
_, _, errCred := aAgent.GetLocalUserCredentials()
|
||||
@@ -1528,9 +1528,9 @@ func TestLiteLifecycle(t *testing.T) {
|
||||
require.NoError(t, bAgent.Close())
|
||||
}()
|
||||
|
||||
bConnected := make(chan interface{})
|
||||
bDisconnected := make(chan interface{})
|
||||
bFailed := make(chan interface{})
|
||||
bConnected := make(chan any)
|
||||
bDisconnected := make(chan any)
|
||||
bFailed := make(chan any)
|
||||
|
||||
require.NoError(t, bAgent.OnConnectionStateChange(func(c ConnectionState) {
|
||||
switch c {
|
||||
|
@@ -69,7 +69,7 @@ func (c *candidateBase) Deadline() (deadline time.Time, ok bool) {
|
||||
}
|
||||
|
||||
// Value implements context.Context.
|
||||
func (c *candidateBase) Value(interface{}) interface{} {
|
||||
func (c *candidateBase) Value(any) any {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ func (c *candidateBase) start(a *Agent, conn net.PacketConn, initializedCh <-cha
|
||||
}
|
||||
|
||||
var bufferPool = sync.Pool{ // nolint:gochecknoglobals
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return make([]byte, receiveMTU)
|
||||
},
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
// Close a net.Conn and log if we have a failure.
|
||||
func closeConnAndLog(c io.Closer, log logging.LeveledLogger, msg string, args ...interface{}) {
|
||||
func closeConnAndLog(c io.Closer, log logging.LeveledLogger, msg string, args ...any) {
|
||||
if c == nil || (reflect.ValueOf(c).Kind() == reflect.Ptr && reflect.ValueOf(c).IsNil()) {
|
||||
log.Warnf("Connection is not allocated: "+msg, args...)
|
||||
|
||||
|
@@ -116,6 +116,6 @@ func (l *Loop) Deadline() (deadline time.Time, ok bool) {
|
||||
}
|
||||
|
||||
// Value is not supported for task loops.
|
||||
func (l *Loop) Value(interface{}) interface{} {
|
||||
func (l *Loop) Value(any) any {
|
||||
return nil
|
||||
}
|
||||
|
@@ -116,7 +116,7 @@ func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault { //nolint:cyclop
|
||||
connsIPv6: make(map[string]*udpMuxedConn),
|
||||
closedChan: make(chan struct{}, 1),
|
||||
pool: &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
// Big enough buffer to fit both packet and address
|
||||
return newBufferHolder(receiveMTU)
|
||||
},
|
||||
|
Reference in New Issue
Block a user