Most of the time with a newly set up tank it is ammonia and nitrates that kill the fish. THe ammonia works on the gills. Others have written about getting that positive bacteria cycle going. That bacteria actually works on the ammonia and converts it to something less toxic for the fish (memory problem this morning).
If you absolutely have to put fish in immediately then its best to make sure you have as large a volume of water as possible and do regular water changes of 10-20% every couple of days, adding conditioner to avoid all the goodies that can be added to the water like flouride and chlorine.
If you have the fish somewhere with lots of light sometimes throwing in some live plants helps but goldfish love to eat plants which means more waste in the water. If you can get them past the first couple months and establish the bacteria cycle to deal with the waste from the fish then you are usually in good shape.
Remember when you rinse that gravel and clean the bowl you are killing all that bacteria which converts the waste to something the fish can handle easier. So save a few cups of that gravel with the bacteria in it when ever you clean the tank. It will help restart that bacteria cycle quicker.
If you are actually running a fiter then this gets easier because you probably aren’t going to tear the tank down and clean it as much. Remember you want to keep that bacteria cycle going. So don’t clean the filter and rinse out all the gravel.