gold ends up, posts a weekly gain of more than $27