Sounds like swim bladder, most likely. This occurs in goldfish a lot when they get too much protein/not enough vegetable matter and their digestive tract gets an impaction. Begin feeding your fish peas exclusively for about a week and it should be ok and then make sure your fish gets plenty of veggies. Ideally a goldfishes diet should be no more than 30% protein(for some reasons all of the flakes and pre-prepared foods are about 65% protein, though). Cucumbers, zucchinis, romaine letuce, and orange slices are all good plant matter for them.