优化部分存在的问题

This commit is contained in:
Yun
2026-05-27 10:56:37 +08:00
parent fa359b2b1a
commit 448116dc0d
11 changed files with 109 additions and 90 deletions
+8 -2
View File
@@ -18,7 +18,10 @@ type Options struct {
func defaultOptions() Options {
u, _ := uuid.NewV7()
u, err := uuid.NewV7()
if err != nil {
u = uuid.New()
}
return Options{
getInterval: time.Second * 2,
@@ -47,7 +50,10 @@ func WithLogger(log logger.Logger) Option {
// 更新周期
func WithUpdateInterval(d time.Duration) Option {
if d.Abs() < time.Second {
if d <= 0 {
d = time.Second * 5
}
if d < time.Second {
d = time.Second * 5
}
return func(o *Options) {
+4 -1
View File
@@ -182,7 +182,10 @@ func (p *Priority) setPriority() (string, error) {
// 解析结果
if resultMap, ok := result.([]interface{}); ok && len(resultMap) == 1 {
resultStr := resultMap[0].(string)
resultStr, ok := resultMap[0].(string)
if !ok {
return "", fmt.Errorf("script unexpected result type: %T", resultMap[0])
}
return resultStr, nil
}