Browse code

replace unreachable returns with panics

Not only is this a more common idiom, it'll make finding bugs easier,
and it'll make porting to Go 1.1 easier.

Go 1.1 will not require the final return or panic because it has a
notion of terminating statements.

Dominik Honnef authored on 2013/04/03 18:18:23
Showing 3 changed files
... ...
@@ -626,7 +626,7 @@ func (container *Container) WaitTimeout(timeout time.Duration) error {
626 626
 	case <-done:
627 627
 		return nil
628 628
 	}
629
-	return nil
629
+	panic("unreachable")
630 630
 }
631 631
 
632 632
 func (container *Container) EnsureMounted() error {
... ...
@@ -184,7 +184,7 @@ func (alloc *PortAllocator) Release(port int) error {
184 184
 	default:
185 185
 		return errors.New("Too many ports have been released")
186 186
 	}
187
-	return nil
187
+	panic("unreachable")
188 188
 }
189 189
 
190 190
 func newPortAllocator(start, end int) (*PortAllocator, error) {
... ...
@@ -202,7 +202,7 @@ func (r *bufReader) Read(p []byte) (n int, err error) {
202 202
 		}
203 203
 		r.wait.Wait()
204 204
 	}
205
-	return
205
+	panic("unreachable")
206 206
 }
207 207
 
208 208
 func (r *bufReader) Close() error {