context please?
 ㅤ
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          ㅤ
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  generally I'm curious about the whole mutexes and concurrent access, does the panic occur upon writing at the same time? And it doesn't happen upon reading?
where did you get this error from?!
 ㅤ
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          ㅤ
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  oh, an example to produce concurrent access error: func main() { m := make(map[string]int, 1) m[`foo`] = 1 var wg sync.WaitGroup wg.Add(2) go func() { for i := 0; i < 1000; i++ { m[`foo`]++ } }() go func() { for i := 0; i < 1000; i++ { m[`foo`]++ } }() wg.Wait() }
ya you shouldn’t do that
you need to use a sync.Mutex or user sync.Map if your concurrent is only write
 ㅤ
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                      
                      
                        
                          ㅤ
                          
                        
                      
                    
                    
                    
                    
                      Автор вопроса
                    
                    
                  Обсуждают сегодня