isPortAvailable checks if the specified port is available. It attempts to listen on the port to determine availability. Returns: - bool: True if the port is available, false otherwise
()
| 295 | // Returns: |
| 296 | // - bool: True if the port is available, false otherwise |
| 297 | func (s *OAuthServer) isPortAvailable() bool { |
| 298 | addr := fmt.Sprintf(":%d", s.port) |
| 299 | listener, err := net.Listen("tcp", addr) |
| 300 | if err != nil { |
| 301 | return false |
| 302 | } |
| 303 | defer func() { |
| 304 | _ = listener.Close() |
| 305 | }() |
| 306 | return true |
| 307 | } |
| 308 | |
| 309 | // IsRunning returns whether the server is currently running. |
| 310 | // |