lock region map on read access
continuous-integration/drone/push Build is passing Details

main
Garionion 10 months ago
parent 89a3cf0eab
commit d8e96c78f8

@ -82,12 +82,6 @@ func (r *RegionCounter) countRegion(region string) {
r.RegionCount[region] = val + 1
}
func (r *RegionCounter) getRegionCount() map[string]int {
r.RLock()
defer r.RUnlock()
return r.RegionCount
}
func main() {
regionCounter := &RegionCounter{
RegionCount: make(map[string]int),
@ -167,7 +161,9 @@ func main() {
})
app.Get("/regions", func(c *fiber.Ctx) error {
return c.JSON(regionCounter.getRegionCount())
regionCounter.RLock()
defer regionCounter.RUnlock()
return c.JSON(regionCounter.RegionCount)
})
app.Listen(":8080")

Loading…
Cancel
Save