mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-10-05 07:56:50 +08:00
update
This commit is contained in:
23
utils/utils.go
Normal file
23
utils/utils.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package utils
|
||||
|
||||
import "strconv"
|
||||
|
||||
func Unwarp[T any](result T, err error) T {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func UnwarpIgnore[T any](result T, _ error) T {
|
||||
return result
|
||||
}
|
||||
|
||||
func GetIntByString(s string) int {
|
||||
i, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return 0
|
||||
} else {
|
||||
return i
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user