docs: 增加 space 包 README.md 文档,优化 room 相关内容可读性
This commit is contained in:
23
utils/super/function.go
Normal file
23
utils/super/function.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package super
|
||||
|
||||
// Handle 执行 f 函数,如果 f 为 nil,则不执行
|
||||
func Handle(f func()) {
|
||||
if f != nil {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
// HandleErr 执行 f 函数,如果 f 为 nil,则不执行
|
||||
func HandleErr(f func() error) error {
|
||||
if f != nil {
|
||||
return f()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// HandleV 执行 f 函数,如果 f 为 nil,则不执行
|
||||
func HandleV[V any](v V, f func(v V)) {
|
||||
if f != nil {
|
||||
f(v)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user