Browse Source

prevent panic if you use API in a wrong way

Victor Vieux 11 years ago
parent
commit
49d7b87cfc
1 changed files with 5 additions and 1 deletions
  1. 5 1
      container.go

+ 5 - 1
container.go

@@ -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 {