You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into unclear behavior when *testing.T is nil, and I'm not sure if it's a bug or intended behavior.
I have a function that can be run from either tests or from a regular go program (in which case *testing.T doesn't exist), and that function contains shell.RunCommandAndGetOutput call. I realise this is probably a non-standard use of library, but still want to understand what's going on.
Describe the bug
I've run into unclear behavior when
*testing.T
isnil
, and I'm not sure if it's a bug or intended behavior.I have a function that can be run from either tests or from a regular go program (in which case
*testing.T
doesn't exist), and that function containsshell.RunCommandAndGetOutput
call. I realise this is probably a non-standard use of library, but still want to understand what's going on.I found that this code will work fine:
But this code will crash will nil ptr dereference:
Resulting in output:
So, to work around this, I had to write this weird-looking construct:
Versions
The text was updated successfully, but these errors were encountered: