Go는 return값이 존재하는 함수에서 만일 조건문 안에서 return할때엔 무조건 if와 else 구문 내에서 전부 return하게 만들어 defer와 같은 상황을 만들게 한다.

여기서 재밌는 점은, 만일 else에 panic이 있다면 이를 인지하고 "return이 없어도 된다"면서 넘어가지만, 만일 이 panic이 다른 함수로 분리되어 있는 상황에서는 panic이기 때문에 값을 리턴할 필요가 없음에도 이를 인지하지 못하고 return을 집어넣으라고 한다.

golang says return value of this function is needed
1

If you have a fediverse account, you can reply to this note from your own instance. Search https://hackers.pub/ap/notes/01989291-78db-7ecd-838b-7601d146f578 on your instance and reply to it.