From 22f1cc955dbf25132e69d126f8db0e5498bffbd2 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Wed, 3 Apr 2013 11:18:23 +0200 Subject: [PATCH] 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. --- container.go | 2 +- network.go | 2 +- utils.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/container.go b/container.go index adb1602162..872bbb000b 100644 --- a/container.go +++ b/container.go @@ -626,7 +626,7 @@ func (container *Container) WaitTimeout(timeout time.Duration) error { case <-done: return nil } - return nil + panic("unreachable") } func (container *Container) EnsureMounted() error { diff --git a/network.go b/network.go index c050609d16..e92a4e5400 100644 --- a/network.go +++ b/network.go @@ -184,7 +184,7 @@ func (alloc *PortAllocator) Release(port int) error { default: return errors.New("Too many ports have been released") } - return nil + panic("unreachable") } func newPortAllocator(start, end int) (*PortAllocator, error) { diff --git a/utils.go b/utils.go index e295239f7f..5ee84239b1 100644 --- a/utils.go +++ b/utils.go @@ -202,7 +202,7 @@ func (r *bufReader) Read(p []byte) (n int, err error) { } r.wait.Wait() } - return + panic("unreachable") } func (r *bufReader) Close() error {