danhab99 to GolangEnglish · 1 year agoI kinda wish there was a better way to do if err != nil in gogithub.comexternal-linkmessage-square10fedilinkarrow-up111arrow-down16file-text
arrow-up15arrow-down1external-linkI kinda wish there was a better way to do if err != nil in gogithub.comdanhab99 to GolangEnglish · 1 year agomessage-square10fedilinkfile-text
minus-squaredbx12linkfedilinkarrow-up1arrow-down5·1 year 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.