Best to do fishless cycling. I think the reason your goldfish died is the way you cleaned the tank. The tank needs bacteria to process fish waste, and by stripping down the tank the way you did, you killed all the bacteria. Generally all that is necessary is vacuuming the substrate (gravel).
The growth of this bacteria allows for the nitrogen cycle to take place. This is called "cycling" a tank. Your goldfish tank was cycled, but when you put the fish back in, the tank was not cycled, and it stressed them out.
In a new tank, you can do a fish cycle (putting in one fish which suffers through the cycle) or fishless cycling, which means putting in some waste directly and waiting for it to be broken down by the bacteria before any fish are introduced. I much prefer fishless cycling. in a SW
tank, you can use a piece of raw, fresh shrimp from a grocery store. You can also use fish food, but I think shrimp is better.
Please take your time and read a lot. I don't want to discourage you, but you should have a solid plan before you get started.