Skip to content

Commit 5e2b5e1

Browse files
bartonipbartondc
authored andcommitted
Check type assertion
1 parent ae37028 commit 5e2b5e1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cli/login_callback.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cli
22

33
import (
4+
"errors"
45
"fmt"
56
"net"
67
"net/http"
@@ -111,8 +112,12 @@ func getAvailablePort() (int, error) {
111112

112113
defer l.Close()
113114

114-
port := l.Addr().(*net.TCPAddr).Port
115-
return port, nil
115+
if tcpAddr, ok := l.Addr().(*net.TCPAddr); ok {
116+
port := tcpAddr.Port
117+
return port, nil
118+
} else {
119+
return -1, errors.New("Unable to get an available port")
120+
}
116121
}
117122

118123
func (s *Server) GenerateCallbackPath() string {

0 commit comments

Comments
 (0)