go知识重新整理

This commit is contained in:
Estom
2021-09-03 05:34:34 +08:00
parent 62309f856a
commit 1bad082e49
291 changed files with 29345 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
/**
* @Author:zhoutao
* @Date:2020/12/12 下午4:14
* @Desc:
*/
package single
import "sync"
//单例模式:使用懒惰模式的单例模式,使用双重检查加锁保证线程安全
type Singleton struct {
}
var singelton *Singleton
var once sync.Once
func GetInstance() *Singleton {
once.Do(func() {
singelton = &Singleton{}
})
return singelton
}