The solution is pretty simple.
My guess is you probably have a small tank with no filtration or air pump to help oxygenate the water. Goldfish or fish in general breathe through their gills and come to surface gulping for air when there is not enough dissolved oxygen available in the water.
Just drop by your local pet store and get an airpump, aquarium airline/air hose (enough to go from your aquarium to a nearby shelf or cabinet), and an air stone to make small bubbles. This should provide your fish with enough dissovled oxygen so that it doesn't have to go to surface to gulp for air anymore.