Barbarians are one of the 2 reasons I rarely collect gold in the AA, I either use it to run 100% sci with negative income, or to buy embassy's. And sometimes to (help) trade tech. from the AI.
The other reason is that the AI will just demand it in tribute.
Here is a small tip: if you are about to lose gold to barbs, and there is nothing you can do to stop it, gift the gold to the AI. If you are lucky, and you choose the AI you gift it to carefully, may even trade it back again next time you trade techs.
Even if you do not see any way to get your gold back, you at least get better AI relations. Good AI relations may be of little value, but it is still better value than losing it to barbs.