prevent panic if you use API in a wrong way

This commit is contained in:
Victor Vieux 2013-11-07 18:54:00 -08:00
parent f417c4b099
commit 49d7b87cfc

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 {