Please Please Please,
Before anyone puts in a resistor to replace the hood switch, look at this first, especially if you are having these symptoms below.
Hood open warning when... rolling up windows, when the HVAC blower is on high, shifting in and out of park, hitting a bump.
If the warning only happens when it is cold, or mostly when it is cold outside. If the truck is randomly alarming or the remote start isn't working or shuts off and truck alarms after it remote starts. Or if when it has been remote stated and you unlock the the doors with the fob and the truck shuts off.
If you have any of these symptoms it is most likely a loose ground!! I have been dealing with these issues for almost 4 years now, but recently got to frequent to handle. After taking it to the dealer with them saying the hood switch is good and they can't find the issue, I stumbled upon this thread and looked up the TSB that was posted by @gmgmgmgmgm. I went outside and after a literal 2 min fix to tighten a nut on the ground all of my issues are gone!!! The truck even starts smoother now!!!
I made some adjustments to ensure that the issues don't come back. I removed the rubber jacket that was over the eyelet to ensure it was getting a complete ground (see attached picture) and took a wire brush to both eyelets and the ground lug. I also added a lock washer so that it doesn't come loose again.
The TSB can be found here..... https://www.tsbsearch.com/GMC/PIT5576C
Hope this helps you're fantom electrical issues like I was having.