A peasant can build a could mine. A unit could summon a goldmine and item could have a pocket goldmine. What is you real question? Do you want someone to try it for you first?
If you want a fully triggered gold mine, this is possible too. I made a lumber mill that workers enter to drop off wood. It's a little different but it's a similar idea.
Lumber.w3x