Address checkPortAvailable linting warnings
This commit is contained in:
parent
cd5b6dc48d
commit
0d3bb647ab
1 changed files with 5 additions and 3 deletions
|
|
@ -38,9 +38,11 @@ func checkPortAvailable(port uint16, subsequent uint16) (bool, error) {
|
||||||
if subsequent == 0 {
|
if subsequent == 0 {
|
||||||
ln, err := net.Listen("tcp", ":"+fmt.Sprint(port))
|
ln, err := net.Listen("tcp", ":"+fmt.Sprint(port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if opErr, ok := err.(*net.OpError); ok {
|
opErr := new(net.OpError)
|
||||||
if sysErr, ok := opErr.Err.(*os.SyscallError); ok {
|
if errors.As(err, &opErr) {
|
||||||
if sysErr.Err == syscall.EADDRINUSE {
|
sysErr := new(os.SyscallError)
|
||||||
|
if errors.As(opErr.Err, &sysErr) {
|
||||||
|
if errors.Is(sysErr.Err, syscall.EADDRINUSE) {
|
||||||
// The port is in use.
|
// The port is in use.
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue