danhab99 to GolangEnglish · 2 years agoI kinda wish there was a better way to do if err != nil in gogithub.comexternal-linkmessage-square10linkfedilinkarrow-up111arrow-down16file-text
arrow-up15arrow-down1external-linkI kinda wish there was a better way to do if err != nil in gogithub.comdanhab99 to GolangEnglish · 2 years agomessage-square10linkfedilinkfile-text
minus-squaredbx12linkfedilinkarrow-up1arrow-down5·2 years agoI too consider that if err != nil a bit complicated to type. Most times, I wrap it away in a function like your Check0. I know that the major “framework” for command line applications (cobra) has a similar logic with its checkError function.
I too consider that
if err != nil
a bit complicated to type. Most times, I wrap it away in a function like yourCheck0
. I know that the major “framework” for command line applications (cobra) has a similar logic with itscheckError
function.