Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I know diddly/squat about Go, but from similar patterns in aeons past, would "nil == err" work as a way to make it stand out?


Just tried this and it appears to be valid in the compiler, formatter and golangci-lint


https://en.wikipedia.org/wiki/Yoda_conditions

Works especially well in languages that can make assignments in if statements, e.g:

if foo = 42 { }


Thank you, I was unaware of this label. Quite descriptive.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: