Skip to content

Clubhouse-148415: fix issue with interface nil not being nil#10

Merged
jfbramlett merged 1 commit intomasterfrom
jfb/ch148415/fix-issue-with-interface-nil-not-being-nil
Aug 18, 2021
Merged

Clubhouse-148415: fix issue with interface nil not being nil#10
jfbramlett merged 1 commit intomasterfrom
jfb/ch148415/fix-issue-with-interface-nil-not-being-nil

Conversation

@jfbramlett
Copy link
Copy Markdown

Go interfaces...my initial attempt worked fine in some cases but didn't cover how we actually use this with our db queries. We create an array of "blank" interfaces that can hold any value (for Scanning into) - this results in one of those kind of weird situations in which a nil value is not really a nil so the checks I had were not working correctly.

This PR expands on the check to determine if the value is nil, I broke it into singular checks to make it a bit easier to debug and see which condition is being met. In this case I need to look at what the interface is referencing to determine if the value is nil (the check inside if reflect.ValueOf(val).Kind() == reflect.Ptr).

Its a bit ugly but so is Go reflection in general.

@shortcut-integration
Copy link
Copy Markdown

@jfbramlett jfbramlett merged commit f5b0cf4 into master Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants