Avoid Naked Parameters

Naked parameters in function calls can hurt readability. Add C-style comments(//) for parameter names when their meaning is not obvious.

BadGood
  1. // func printInfo(name string, isLocal, done bool)
  2.  
  3. printInfo("foo", true, true)
  1. // func printInfo(name string, isLocal, done bool)
  2.  
  3. printInfo("foo", true / isLocal /, true / done /)

Better yet, replace naked bool types with custom types for more readable andtype-safe code. This allows more than just two states (true/false) for thatparameter in the future.

  1. type Region int
  2.  
  3. const (
  4. UnknownRegion Region = iota
  5. Local
  6. )
  7.  
  8. type Status int
  9.  
  10. const (
  11. StatusReady = iota + 1
  12. StatusDone
  13. // Maybe we will have a StatusInProgress in the future.
  14. )
  15.  
  16. func printInfo(name string, region Region, status Status)