Goldschmidt went 1-for-2 at the plate but his one hit was a three-run homer and he drove in runs on two sacrifice flies.
Aaron Hill was 3-for-5 with three runs scored for the Diamondbacks, who remained 5 1/2 games out of the wild card.
Josh Collmenter (5-3) earned the victory with one run on two hits and four strikeouts over five innings.
Tim Lincecum (10-15) had his personal winning streak end at three games. Lincecum left after four-plus innings in which he allowed seven runs on five hits and four walks.