Contraction of gosh (“God”, euphemism) + dang (“damn”, euphemism) + it. Compare goshdarnit.
goshdangit