mirror of https://github.com/docker/docs.git
driverutil: removes unused err return
Signed-off-by: André Carvalho <andre.carvalho@corp.globo.com>
This commit is contained in:
parent
716a8d133f
commit
7c3f96c235
|
|
@ -4,13 +4,10 @@ import "strings"
|
|||
|
||||
// SplitPortProto splits a string in the format port/protocol, defaulting
|
||||
// protocol to "tcp" if not provided.
|
||||
func SplitPortProto(raw string) (port string, protocol string, err error) {
|
||||
func SplitPortProto(raw string) (port string, protocol string) {
|
||||
parts := strings.SplitN(raw, "/", 2)
|
||||
if len(parts) == 1 {
|
||||
protocol = "tcp"
|
||||
} else {
|
||||
protocol = parts[1]
|
||||
return parts[0], "tcp"
|
||||
}
|
||||
port = parts[0]
|
||||
return port, protocol, nil
|
||||
return parts[0], parts[1]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,21 +11,15 @@ func TestSplitPortProtocol(t *testing.T) {
|
|||
raw string
|
||||
expectedPort string
|
||||
expectedProto string
|
||||
expectedErr bool
|
||||
}{
|
||||
{"8080/tcp", "8080", "tcp", false},
|
||||
{"90/udp", "90", "udp", false},
|
||||
{"80", "80", "tcp", false},
|
||||
{"8080/tcp", "8080", "tcp"},
|
||||
{"90/udp", "90", "udp"},
|
||||
{"80", "80", "tcp"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
port, proto, err := SplitPortProto(tc.raw)
|
||||
port, proto := SplitPortProto(tc.raw)
|
||||
assert.Equal(t, tc.expectedPort, port)
|
||||
assert.Equal(t, tc.expectedProto, proto)
|
||||
if tc.expectedErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue