func (i *instance) Set(params ...interface{}) (err error) {
	name, inst := factory.ParseParams(params...)
	metaData := factory.CastMetaData(inst)
	if metaData == nil {
		metaData = factory.NewMetaData(inst)
	}
	old, ok := i.instMap.Get(name)
	if ok {
		oldMd := factory.CastMetaData(old)
		if oldMd.Instance != nil {
			err = fmt.Errorf("instance %v is already taken", name)
			return
		}
	}
	i.instMap.Set(name, metaData)
	return
}
Set save instance
package instantiate
import (
	"fmt"
	"hidevops.io/hiboot/pkg/factory"
	"hidevops.io/hiboot/pkg/utils/cmap"
)
type instance struct {
	instMap cmap.ConcurrentMap
}
func newInstance(instMap cmap.ConcurrentMap) factory.Instance {
	if instMap == nil {
		instMap = cmap.New()
	}
	return &instance{
		instMap: instMap,
	}
}
func (i *instance) Get(params ...interface{}) (retVal interface{}) {
	name, obj := factory.ParseParams(params...)
	if md, ok := i.instMap.Get(name); ok {
		metaData := factory.CastMetaData(md)
		if metaData != nil {
			switch obj.(type) {
			case factory.MetaData:
				retVal = metaData
			default:
				retVal = metaData.Instance
			}
		}
	}
	return
}