barakmich / go-nyet

More aggressive `go vet`
BSD 2-Clause "Simplified" License
89 stars 8 forks source link

select statement assignment bug #15

Closed jzelinskie closed 9 years ago

jzelinskie commented 9 years ago

I've inlined the output above the indicated lines.

...
    // Declared variable `timeout` which goes unused
    timeout := time.After(processIdleTimeout)
    for {
        select {
        case err := <-notifyChan:
            if err != nil {
                return notifyWriter.buf.Bytes(), err
            }

            // `timeout` gets covered here 
            timeout = time.After(processIdleTimeout)

        case <-timeout:
            if err := cmd.Process.Kill(); err != nil {
                log.Fatalf("failed to kill hung process: %s", err)
            }
            return notifyWriter.buf.Bytes(), errors.New("killed process due to inactivity timeout")

        case err := <-doneChan:
            return notifyWriter.buf.Bytes(), err
        }
    }
}