I'm not quite sure where 김 came from, unfortunately, but 금 is the character that means gold in Korean, and it's a different syllable entirely. Did it become 김 over time? I couldn't say, because I don't have the documentation to prove it one way or the other.