Skip to content
  • Jesse Szwedko's avatar
    Avoid generating `go vet` identifiable unreachable code · b0a198c2
    Jesse Szwedko authored
    This:
    
    * Moves statements included simply to guard against build errors for
      unused labels to a separate section
    * Wraps statements simply included to avoid including unused labels with
      an `if false { ... }` to avoid `go vet` determining that subsequent
      lines won't be hit
    * Wraps final rule with a `if true { ... }` to avoid `go vet`
      determining that the `panic` will never be hit if the user includes
      a `return` statement in their final rule
    
    These changes together trick `go vet` into not identifying the
    unreachable code though this is purely because it isn't intelligent
    enough to notice the static conditionals.
    
    At least in this simple program:
    
    ```
    package main
    
    import "fmt"
    
    func main() {
      if true {
        fmt.Println("vim-go")
      }
    }
    ```
    
    The Go 1.13.4 compiler elides the conditional.
    b0a198c2