refactor: add comment about concurrency in RegisterDefaultValueFactory

This commit is contained in:
yusing
2025-10-01 20:10:33 +08:00
parent c2c22dca0b
commit 1322951f26

View File

@@ -44,6 +44,8 @@ var mapUnmarshalerType = reflect.TypeFor[MapUnmarshaller]()
var defaultValues = make(map[reflect.Type]func() any)
// RegisterDefaultValueFactory registers a factory function for a type.
// This is not concurrent safe. Intended to be used in init functions.
func RegisterDefaultValueFactory[T any](factory func() *T) {
t := reflect.TypeFor[T]()
if t.Kind() == reflect.Pointer {