The common comet (feeder) goldfish need a minimum of 20 gals, and that is for one of them. In fact, I believe they actually need more as they can grow 12", correct? They "can" live in smaller tanks, but only for a short while, as their bodies may stop growing, but their organs and such doesn't.. so by only giving them not even a fraction what is needed, you are slowly and eventually painfully killing them.
Goldfish can and do live for decades.. 20+ years easily.. and if given the proper room, temp and filtration, are very hardy fish. A goldfish that dies after a few months to a couple years, then you definitely will need to reevaluate your set up. And with ammonia burns being present, it just means that it won't be a long time until the poor thing passes..