Go Error Check Fallthrough
> Asks if 'if err != nil' is really that bad > Screenshot example shows accidental fallthrough from error case to success case Do we really need to discuss further? is 'if err != nil' really that bad? match atoi "6942" with | Error -> Printf.printf "failed to parse int\n" | Ok n -> Printf.printf "hello %d\n" n n, err := atoi("6942") if err != nil { fmt.Printf("failed to parse int\n") } fmt.Printf("hello %d\n", n)
A programming meme contrasts pattern matching in a functional language with Go's explicit error check. The Go example prints the success message even after parsing fails because execution falls through after the error branch, making the criticism of `if err != nil` look obviously justified. It is shared as a sarcastic reaction to debates about Go error handling. EN: A programming meme contrasts pattern matching in a functional language with Go's explicit error check. The Go example prints the success message even after parsing fails because execution falls through after the error branch, making the criticism of `if err != nil` look obviously justified. It is shared as a sarcastic reaction to debates about Go error handling.
programmer / программистsocial media post / публикация в соцсетиcode screenshot / скриншот кодаGo logo / логотип GoOCaml logo / логотип OCamlterminal-style code / код в стиле терминалаerror message / сообщение об ошибкеsuccess message / сообщение об успехеtext editor window / окно текстового редактораwhite background / белый фонbeige code panel / бежевая панель с кодомprofile avatar / аватар профиля
- @ithueti / 14830 2024-12-18
- Type
- image
- Size
- 781×800 · 74.9 KiB
- Mood
- sarcastic
- Language
- en
- Added