Antonboom/nilnil

Detect the opposite situation?

Closed this issue · 4 comments

return entity, errors.New("something went wrong")

// should be
return nil, errors.New("something went wrong")
itimky commented

That's a great idea!
What do you think about a separate option for this detection to preserve backwards compatibility?

@itimky, hi!

Nice to see you 🙂

I agree. If you have time, please contribute. Or I can do this if it is relevant to real life (at the time of creating the issue I was not sure that this was a real case).

But I am not sure about the best naming for new option. Maybe --detect-reverse=true 🤷

Glad to see you again too, pal 🤗

I tried to find some real life cases and did not find any 🤔

On a second thought, I saw constructions like this:

func get(..) (*Entity, error) { .. }

func SomeFn() (*Entity, error) {
  ..
  
  return get(..)
}

Is such case relevant?