-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nil *testing.T handling #1355
Labels
bug
Something isn't working
Comments
Hello, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: