Open hueng opened 4 years ago
如下代码,并发访问getMockTime(),有安全问题吗?想确认下,我测试没发现并发问题。
func init() { gomonkey.ApplyFunc(time.Now, func() time.Time { mockTime := int64(1588239281376264700) sec := mockTime / 1000000000 nsec := mockTime % 1000000000 return time.Unix(sec, nsec) }) } func getMockTime() { // output: 2020-04-30 17:34:41.3762647 +0800 CST fmt.Println("mock time:", time.Now()) }
多读没有问题
这个并发安不安全是看你自己的func实现吧
如下代码,并发访问getMockTime(),有安全问题吗?想确认下,我测试没发现并发问题。