Unnecessary Else

If a variable is set in both branches of an if, it can be replaced with asingle if.

BadGood
  1. var a int
  2. if b {
  3. a = 100
  4. } else {
  5. a = 10
  6. }
  1. a := 10
  2. if b {
  3. a = 100
  4. }