Your goldfish has septicemia as the result of poor water conditions. It seems likely that, though it has lived a surprisingly long time in those conditions, the effects of cramping, ammonia, and high waste concentration in the water are finally killing it. You need to get those animals into a bigger tank, and fast. As others mentioned, don't even worry about an aquarium right now; they'd be better off in a big rubbermaid tub than in that 2.5. I have two commons, each four inches long, living in a 30 gallon tank, and I am allready going to be upgrading since I have to clean them so often. They are only a year old and are 4-5 inches each, so you can see how much your fish have been stunted by living in a tiny tank; if the ammonia doesn't kill them, organ compression eventually will.
Once you get the goldie in the bigger tank, you will want to treat with an antibiotic, as clean water alone my not be enough at this point. Maracyn 2 and Tetracyclene are good strong antibiotics that deal well with internal infection. If he is still eating, you could also try an antibacterial food in conjunction with water treatment to speed recovery time.