golang 锁bug 记录
package routes
import (
"fmt"
"sync"
"testing"
"time"
)
var all_lock_test sync.RWMutex
func TestSendGiftInfo_SendBlind(t *testing.T) {
if !all_lock_test.TryRLock() {
return
}
defer all_lock_test.RUnlock()
go func() {
all_lock_test.Lock()
defer all_lock_test.Unlock()
fmt.Println("配置更新")
}()
time.Sleep(time.Second)
rDeal()
}
func rDeal() {
all_lock_test.RLock()
defer all_lock_test.RUnlock()
fmt.Println("处理业务完毕")
}