head
temp := head
// Since temp is a pointer, any modifications made to it will also
// impact head. So when you set temp.Next here, you're also setting
// head.Next. Since prev is always nil on the first iteration, you've
// set head.Next = nil.
temp.Next = prev
prev = temp
// This will set head to nil, always.
head = head.Next
head = head.Next
Effectively what the second version does is snip off all elements of the list except the first one. If you didn't make a reference to the second element before calling this function, then they are now off in limbo and will get garbage-collected.
temp := headtempheadtemptemp.Next = prevhead
head = head.Nextheadhead.Nextheadtemp