Skip to content

Files

Latest commit

 

History

History
28 lines (22 loc) · 491 Bytes

early-return.md

File metadata and controls

28 lines (22 loc) · 491 Bytes

Pattern: Missing use of early return

Issue: -

Description

In GO it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. This rule spots constructions like

if cond {
  // do something
} else {
  // do other thing
  return ...
}

that can be rewritten into more idiomatic:

if ! cond {
  // do other thing
  return ...
}

// do something

Further Reading