瀏覽代碼

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 12 年之前
父節點
當前提交
22f1cc955d
共有 3 個文件被更改,包括 3 次插入3 次删除
  1. 1 1
      container.go
  2. 1 1
      network.go
  3. 1 1
      utils.go

+ 1 - 1
container.go

@@ -626,7 +626,7 @@ func (container *Container) WaitTimeout(timeout time.Duration) error {
 	case <-done:
 	case <-done:
 		return nil
 		return nil
 	}
 	}
-	return nil
+	panic("unreachable")
 }
 }
 
 
 func (container *Container) EnsureMounted() error {
 func (container *Container) EnsureMounted() error {

+ 1 - 1
network.go

@@ -184,7 +184,7 @@ func (alloc *PortAllocator) Release(port int) error {
 	default:
 	default:
 		return errors.New("Too many ports have been released")
 		return errors.New("Too many ports have been released")
 	}
 	}
-	return nil
+	panic("unreachable")
 }
 }
 
 
 func newPortAllocator(start, end int) (*PortAllocator, error) {
 func newPortAllocator(start, end int) (*PortAllocator, error) {

+ 1 - 1
utils.go

@@ -202,7 +202,7 @@ func (r *bufReader) Read(p []byte) (n int, err error) {
 		}
 		}
 		r.wait.Wait()
 		r.wait.Wait()
 	}
 	}
-	return
+	panic("unreachable")
 }
 }
 
 
 func (r *bufReader) Close() error {
 func (r *bufReader) Close() error {