If it's something they'll eat, go ahead. When we swat a fly, it usually goes in a tank. There are also lots of live foods (bugs or worm relatives) that you can grow to feed your fish. Usually it's cheaper than buying prepared food. Some fish will only eat live food, or won't breed without it, but goldfish aren't that picky.