This is a common problem found among goldfish and can usually be treated by lowering the oxygen level in their tank, reducing the oxygen puts things back in balance and your goldfish will no longer float.
1 put a pea on a tooth pick so it will float where your fish can eat it and feed him a fresh one everyday for a few days
after a few days he should be able to sink and swim freely now only feed him sinking fish food
If they are floating, that means something is terribly wrong. They usually only float when they are dead or keep floating up to the surface and then fight to swim back down when they are in the process of dying. Sorry.
This means that they have absorbed air in a duct and I don't really think there is much you can do for them. I have seen this happen to only a few fish in my life and it is not a good outcome.