This is because your fish is not getting enough roughage in its diet. Goldfish and all herbivorous fish and animals need a lot of roughage in their food to ensure their digestive system works properly.
Feed a good quality food such as FishScience Goldfish Flakes which contain optimal levels of roughage. Feeding Daphnia is also a good way to quickly overcome such problems.