diff --git a/internal/host/host.go b/internal/host/host.go index 078660be5..d5cc7ffa3 100644 --- a/internal/host/host.go +++ b/internal/host/host.go @@ -14,9 +14,6 @@ func ExtractHostPort(addr string) (host string, port uint64, err error) { return } port, err = strconv.ParseUint(ports, 10, 16) //nolint:gomnd - if err != nil { - return - } return } @@ -40,11 +37,11 @@ func Extract(hostPort string, lis net.Listener) (string, error) { return "", err } if lis != nil { - if p, ok := Port(lis); ok { - port = strconv.Itoa(p) - } else { + p, ok := Port(lis) + if !ok { return "", fmt.Errorf("failed to extract port: %v", lis.Addr()) } + port = strconv.Itoa(p) } if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]" && addr != "::") { return net.JoinHostPort(addr, port), nil @@ -61,7 +58,8 @@ func Extract(hostPort string, lis net.Listener) (string, error) { } if iface.Index < lowest || result == nil { lowest = iface.Index - } else if result != nil { + } + if result != nil { continue } addrs, err := iface.Addrs()