Gold fish get a bit to large and at the potential size, reaching around 10 inches they will most likely harass the betta
Fancy goldfish usually have long flowing fins and flashy colors In My Experience, when they are smaller bettas will most likely attack them
Goldfish require high levels oxygen to thrive, to attain this. you would typically need high levels of flow. and bettas do not like this type of habitat, it greatly stresses them out
Goldifsh produce high levels of waste/ammonia which is toxic to all fish. In a 5 gallon the ammonia/nitrite content would build up very quickly even if the tank is cycled. unless you make the commitment to the fish and do daily water changes until you can upgrade the goldfish's tank
Bettas and goldfish have different temperature requirements. while fancy goldfish do usually prefer higher temperatures than the less modified common goldfish. they still like cooler temperatures than most tropical fish
Bettas and goldfish have different dietary requirements. goldfish are mainly omnivorous fish but appreciate vegetational matter more than they like meatier foods, while bettas are mainly carnivorous and cant digest the preferred food by goldfish.
Goldfish will get stunted in a tank of that size due to the buildup of growth hormones. naturally they emit growth hormones and once the hormones reach a certain level and the growth hormone content rises they will stop growing on the outside, while there organs keep growing causing long term deformation. I would recommend a 40 gallon tank for 2 pearlscale goldfish