prevent panic if you use API in a wrong way

Upstream-commit: 49d7b87cfc4385470a5ecf181f92c13b8391c002
Component: engine
This commit is contained in:
Victor Vieux
2013-11-07 18:54:00 -08:00
parent 2f4c3fdf6d
commit b89c66d724

View File

@ -133,7 +133,11 @@ type PortBinding struct {
type Port string
func (p Port) Proto() string {
return strings.Split(string(p), "/")[1]
parts := strings.Split(string(p), "/")
if len(parts) == 1 {
return "tcp"
}
return parts[1]
}
func (p Port) Port() string {