update
parent
4d51d0a1d0
commit
db3d256bd7
16
common.go
16
common.go
|
@ -90,3 +90,19 @@ func ExistFile(file string) bool {
|
|||
// 其他错误
|
||||
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)
|
||||
}
|
||||
|
||||
func (c *Config) Exists(key string) bool {
|
||||
c.RLock()
|
||||
defer c.RUnLock()
|
||||
return c.kof.Exists(key)
|
||||
}
|
||||
|
||||
func (c *Config) GetString(key string) string {
|
||||
c.RLock()
|
||||
defer c.RUnLock()
|
||||
|
|
Loading…
Reference in New Issue