update
This commit is contained in:
16
common.go
16
common.go
@@ -90,3 +90,19 @@ func ExistFile(file string) bool {
|
|||||||
// 其他错误
|
// 其他错误
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UniqueSlice[T comparable](rawSlice []T) []T {
|
||||||
|
if len(rawSlice) <= 1 {
|
||||||
|
return rawSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
uniqueSlice := make([]T, 0, len(rawSlice))
|
||||||
|
has := make(map[T]bool, len(rawSlice))
|
||||||
|
for _, v := range rawSlice {
|
||||||
|
if !has[v] {
|
||||||
|
uniqueSlice = append(uniqueSlice, v)
|
||||||
|
has[v] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uniqueSlice
|
||||||
|
}
|
||||||
|
|||||||
@@ -225,6 +225,12 @@ func (c *Config) Get(key string) any {
|
|||||||
return c.kof.Get(key)
|
return c.kof.Get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Config) Exists(key string) bool {
|
||||||
|
c.RLock()
|
||||||
|
defer c.RUnLock()
|
||||||
|
return c.kof.Exists(key)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Config) GetString(key string) string {
|
func (c *Config) GetString(key string) string {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
defer c.RUnLock()
|
defer c.RUnLock()
|
||||||
|
|||||||
Reference in New Issue
Block a user