Race conditions
From the start, this strategy has a major issue. If both threads look at the map at the same time, they will see that page1.html is ready to be scraped. They would then both update the value for page1.html to "WORKING", and go on to scrape the same site at the same time! This would not only be a duplicated effort, but it would also create an extra load on the example.com server. An even worse situation is if one thread is updating the status to "WORKING" while the other thread is attempting to read the status. Then, your scraper will crash. Concurrent read and/or write operations are not allowed in Go.
This situation is known as a race condition and is one of the most common issues you will run into as you build concurrent ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access