Gold is rare, compared to just about every other element, in accessible areas of earth. All the gold ever discovered on Earth would fit inside a 23 meter (75 foot) cube. This is about 244 thousand tons, in all of human history.
Compare this to iron, where just the United States produces 46 Million tons in 2022 alone.
There is plenty of gold deep within the Earth - it is very dense, so it sank towards the core when Earth was recently formed - but on the surface and the proximal crust, it is not found in abundance.
The form of silicon used in semiconductor manufacturing, specific formations of sand, is becoming harder to source from the environment. Silicon the element is incredibly abundant - the vast majority of all rocks on Earth are silicates - so there isn't a risk that we run out of silicon itself any time soon.
What may happen, in several decades, is an increase in price due to the need to process more abundant rocks to obtain pure silicon.