First of all, you should provide the ideal environment to your goldfish in your tank. You should maintain the ideal temperature, pH, water hardness, etc. You should also feed high-quality food to your goldfish. And feed a variety of food. Lastly, you should keep up with the regular maintenance of your goldfish tank and keep the tank clean. Besides, there are several other things goldfish like in their tank. I have written a detailed article on this topic. You can read it here.