It could have been a number of things - but fundamentally it was a swim bladder problem. I have kept goldfish now for 12 years (with one of the orignals still surviving despite an ovarian cyst/ tumour) and have found that when they get that ill, it is hard to bring them back, no matter how much medicine you add.
Most fish illness problems relate to water quality one way or another - which in turn relates to how many fish you have, what type they are, how big the tank is, how you fillter the water, how often and how much water you change.
My first line of defence is salt - routinely adding a teaspoon per 10l / 2gal of aquarium salt or sea salt crystals (not cooking salt as this contains anti caking agents) on a normal water change and when they look sick putting them in smaller tank - to isolate them if it is a disease and to increase the salt concentration to about 4 tsp per 10l , if this fails a short term (5 minutes) salt bath in high concentration solution.
I have also used "melafix" and "pimafix" as anti bacterial and anti fungal treatments - however it is essential to follow the instructions - as these are not readily broken down by the bugs in the tank/ fillter.