fix: apply Gemini Pro review — maps.Clone for crash metadata
Prevents external mutation of crash handler metadata after construction. Uses maps.Clone (Go 1.21+) as suggested by Gemini Pro review. Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
d1c9d4e4ad
commit
81eba2777a
1 changed files with 3 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ package core
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
|
|
@ -48,7 +49,8 @@ func WithCrashFile(path string) CrashOption {
|
|||
|
||||
// WithCrashMeta adds metadata included in every crash report.
|
||||
func WithCrashMeta(meta map[string]string) CrashOption {
|
||||
return func(h *CrashHandler) { h.meta = meta }
|
||||
cloned := maps.Clone(meta)
|
||||
return func(h *CrashHandler) { h.meta = cloned }
|
||||
}
|
||||
|
||||
// WithCrashHandler sets a callback invoked on every crash.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue