github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/utils/yerror/error.go (about) 1 package yerror 2 3 import ( 4 "log/slog" 5 6 "github.com/Asutorufa/yuhaiin/pkg/log" 7 ) 8 9 func Must[T any](v T, err error) T { 10 if err != nil { 11 log.Output(1, slog.LevelError, "must error", "err", err) 12 panic(err) 13 } 14 return v 15 } 16 17 func Ignore[T any](v T, err error) T { 18 if err != nil { 19 log.Output(1, slog.LevelWarn, "ignore error", "err", err) 20 } 21 return v 22 } 23 24 func Ignore2[T, T1, T2 any](v T, _ T1, _ T2) T { return v }