Why do you think the fish is constipated?
If a gold fish is eating well, you should not see much poop. It is true that goldies poop lots, but "healthy" poop are short bits (1/8"-1/4") that disintegrate in the tank fairly promptly. You shouldn't see more than a few bits & pieces even in a bare bottom tank.
Now, if you see a long string of poop coming out the fish <I've seen fish trailing poop that is 2-3" long>, that would indicate constipation. Feeding peas is a great idea. <Shelled, blanched & chopped up.> So is feeding other veggies - cucumbers, zucchinis, etc. Ideally, you should be feeding veggies to Goldies every few days. <Goldies fanatics will feed home made food exclusively!> Goldfish also do better with sinking pellets rather than flakes. <For floating pellets, soak in a bit of water first till they sink.>
A symptom of more advanced constipation is swim bladder dysfunction. In this case, there is gas in the gut (from stool impaction), or possibly direct pressure on the swimbladder from the constipation. The fish will have trouble staying upright, or might have problem either staying in the bottom or at the top of the tank. Fasting for a day or so followed by peas may help. Epsom salt is needed for resistent cases.