MCPcopy
hub / github.com/go-gorm/gorm / setupNewValuePool

Method setupNewValuePool

schema/field.go:992–1011  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

990}
991
992func (field *Field) setupNewValuePool() {
993 if field.Serializer != nil {
994 serializerValue := reflect.Indirect(reflect.ValueOf(field.Serializer))
995 serializerType := serializerValue.Type()
996 field.NewValuePool = &sync.Pool{
997 New: func() interface{} {
998 si := reflect.New(serializerType)
999 si.Elem().Set(serializerValue)
1000 return &serializer{
1001 Field: field,
1002 Serializer: si.Interface().(SerializerInterface),
1003 }
1004 },
1005 }
1006 }
1007
1008 if field.NewValuePool == nil {
1009 field.NewValuePool = poolInitializer(reflect.PointerTo(field.IndirectFieldType))
1010 }
1011}

Callers 1

setupValuerAndSetterMethod · 0.95

Calls 3

TypeMethod · 0.65
NewMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected