refactor: use atomic.Int64 for underlying GetId implementation

This commit is contained in:
2025-08-01 16:27:39 -05:00
parent 393191ccb5
commit 378bc29e7e

View File

@@ -5,6 +5,7 @@ import (
"log/slog" "log/slog"
"reflect" "reflect"
"runtime" "runtime"
"sync/atomic"
"time" "time"
"github.com/golang-module/carbon" "github.com/golang-module/carbon"
@@ -16,11 +17,12 @@ type EnabledDisabledInfo struct {
RunOnError bool RunOnError bool
} }
var id int64 = 0 var (
id atomic.Int64 // default value is 0
)
func GetId() int64 { func GetId() int64 {
id += 1 return id.Add(1)
return id
} }
// Parses a HH:MM string. // Parses a HH:MM string.