Merge pull request #75 from jimen0/simplifications-patch

all: simplify logic statements and remove unneeded conversions
This commit is contained in:
Ice3man 2020-08-27 08:54:55 -07:00 committed by GitHub
commit 4c5b8e6ffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 12 deletions

View File

@ -39,7 +39,7 @@ func NewDialer(options Options) (DialerFunc, error) {
finalIps = append(finalIps, ip)
}
}
if err != nil || len(finalIps) <= 0 {
if err != nil || len(finalIps) == 0 {
return nil, &NoAddressFoundError{}
} // Dial to the IPs finally.
for _, ip := range ips {

View File

@ -26,7 +26,7 @@ func (c *CustomPorts) Set(value string) error {
// splits on comma
potentialPorts := strings.Split(value, ",")
// check if port is a single integer value or needs to be expanded futher
// check if port is a single integer value or needs to be expanded further
for _, potentialPort := range potentialPorts {
potentialRange := strings.Split(strings.TrimSpace(potentialPort), "-")
// it's a single port?

View File

@ -14,10 +14,7 @@ func FileExists(filename string) bool {
// FolderExists checks if a folder exists
func FolderExists(folderpath string) bool {
_, err := os.Stat(folderpath)
if os.IsNotExist(err) {
return false
}
return true
return !os.IsNotExist(err)
}
// HasStdin determines if the user has piped input

View File

@ -117,7 +117,7 @@ func (h *HTTPX) Do(req *retryablehttp.Request) (*Response, error) {
return nil, err
}
resp.Raw = string(rawresp)
resp.Raw = rawresp
var respbody []byte
// websockets don't have a readable body

View File

@ -5,11 +5,7 @@ import "net"
// IsCidr determines if the given ip is a cidr range
func IsCidr(ip string) bool {
_, _, err := net.ParseCIDR(ip)
if err != nil {
return false
}
return true
return err == nil
}
// IsIP determines if the given string is a valid ip