Paul Goldschmidt hit a go-ahead homer in the sixth inning to help Ian Kennedy snap a five-start losing streak, and the Arizona Diamondbacks avoided a three-game sweep with a 4-1 victory over the San Francisco Giants on Wednesday night.