Skip to content

fix error linting #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nat/nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,22 @@ func ParsePortSpec(rawPort string) ([]PortMapping, error) {
ip = rawIP
}
if ip != "" && net.ParseIP(ip) == nil {
return nil, fmt.Errorf("invalid IP address: %s", ip)
return nil, errors.New("invalid IP address: " + ip)
}
if containerPort == "" {
return nil, fmt.Errorf("no port specified: %s<empty>", rawPort)
}

startPort, endPort, err := ParsePortRange(containerPort)
if err != nil {
return nil, fmt.Errorf("invalid containerPort: %s", containerPort)
return nil, errors.New("invalid containerPort: " + containerPort)
}

var startHostPort, endHostPort uint64 = 0, 0
if len(hostPort) > 0 {
startHostPort, endHostPort, err = ParsePortRange(hostPort)
if err != nil {
return nil, fmt.Errorf("invalid hostPort: %s", hostPort)
return nil, errors.New("invalid hostPort: " + hostPort)
}
}

Expand Down
6 changes: 3 additions & 3 deletions nat/parse.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package nat

import (
"fmt"
"errors"
"strconv"
"strings"
)

// ParsePortRange parses and validates the specified string as a port-range (8000-9000)
func ParsePortRange(ports string) (uint64, uint64, error) {
if ports == "" {
return 0, 0, fmt.Errorf("empty string specified for ports")
return 0, 0, errors.New("empty string specified for ports")
}
if !strings.Contains(ports, "-") {
start, err := strconv.ParseUint(ports, 10, 16)
Expand All @@ -27,7 +27,7 @@ func ParsePortRange(ports string) (uint64, uint64, error) {
return 0, 0, err
}
if end < start {
return 0, 0, fmt.Errorf("invalid range specified for port: %s", ports)
return 0, 0, errors.New("invalid range specified for port: " + ports)
}
return start, end, nil
}
Loading