github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/simple/testdata/src/LintRedundantBreak/LintRedundantBreak.go (about)

     1  package pkg
     2  
     3  func fn(x int) {
     4  	switch x {
     5  	case 1:
     6  		println()
     7  		break // MATCH /redundant break/
     8  	case 2:
     9  		println()
    10  	case 3:
    11  		break // don't flag cases only consisting of break
    12  	case 4:
    13  		println()
    14  		break
    15  		println()
    16  	case 5:
    17  		println()
    18  		if true {
    19  			break // we don't currently detect this
    20  		}
    21  	case 6:
    22  		println()
    23  		if true {
    24  			break
    25  		}
    26  		println()
    27  	}
    28  
    29  label:
    30  	for {
    31  		switch x {
    32  		case 1:
    33  			println()
    34  			break label
    35  		}
    36  	}
    37  }