Simplify Singleton usage by leveraging Go 1.18's generics

This commit is contained in:
Deluan
2022-07-27 12:15:05 -04:00
parent a2d9aaeff8
commit d613b19306
6 changed files with 45 additions and 38 deletions
+1 -2
View File
@@ -19,7 +19,7 @@ var (
)
func Db() *sql.DB {
instance := singleton.Get(&sql.DB{}, func() interface{} {
return singleton.GetInstance(func() *sql.DB {
Path = conf.Server.DbPath
if Path == ":memory:" {
Path = "file::memory:?cache=shared&_foreign_keys=on"
@@ -32,7 +32,6 @@ func Db() *sql.DB {
}
return instance
})
return instance.(*sql.DB)
}
func EnsureLatestVersion() {