The main issue with feeding goldfish is how much. Goldfish will typically eat just about everything that is given to them. Apparently in the wild this is no problem, but in captivity domestic goldfish basically will not survive if fed to anywhere near their capacity to eat. There are exceptions; very young fish need to be fed a considerable amount to get reasonable growth rates and some foods that are essentially only roughage can be fed quite freely. But in general it is necessary to limit the amount of food provided to your goldfish.
What happens if you overfeed your goldfish? Many people have described the digestive track of the goldfish as basically a straight tube. In the simplest scenario, if you feed too much, food being pushed in the front end of the "tube" pushes food out the back end ... before it is fully digested. If your goldfish's poops look just like his food, this could be an indication of overfeeding.
For robust, wild-type goldfish overfeeding's main problem is water quality; the semi-digested food makes it harder to keep the water of sufficient cleanliness without frequent massive water changes. This may explain why overfeeding is not a problem in the wild. However, for fat-bodied fancy goldfish, that straight tube tends to have a few kinks in it; just like with people, lack of roughage and too rich a diet can cause significant problems. For more information, see the discussion on swimbladder problems.
All right, now that you're convinced that whatever amount you are feeding is probably the wrong amount, what is the right amount? The quick answer is that if you don't have water quality problems, don't have problems with your fish floating, and the fish seem active and healthy, you are probably doing just fine. And, uh, scatologically, if the poops are in quarter to half inch sinking chunks, this is good too. Otherwise you probably are overfeeding or not feeding quite the right diet.
A common recommendation is to feed goldfish two mouthfuls twice a day. I was troubled for a long time about what is, exactly, a goldfish mouthful. I believe it is as much as a goldfish will take in its mouth before it stops "gobbling" and starts chewing. Determining the correct amount of food for your fish is then relatively easy; toss in units of food until everybody stops chasing and then figure about double that for a feeding. This actually ends up being quite a bit of food.
It has been suggested that goldfish are naturally grazers, eating small amounts continuously. It does seem that goldfish have fewer problems with many small meals than they do with one large one per day. So, if you can conveniently do it, a regime of one mouthful four times a day will be better that two mouthfuls twice daily. And, conversely, feeding four mouthfuls in one feeding will probably give you problems.
Unfortunately, it is pretty clear that the most entertaining thing in a goldfish's life is eating. Most owners would like their fish to be as intellectually stimulated as is, uh, possible. This can lead to overfeeding. I won't go overboard on the anthropomorphization here, but, like people, low calorie high-roughage foods can be fairly freely fed without digestive problems. Romaine lettuce is a good example: it is reasonably nutritive (much better than iceberg lettuce), but is also mostly water and fiber. A leaf clipped inside the tank will last days if submerged and the fish will nibble away on it. The only downside is that the resulting lettuce puree in the tank can plug filters pretty quickly. But otherwise this is an excellent option, I think.