func Resolve(data []*factory.MetaData) (result []*factory.MetaData, err error) {
	if len(data) != 0 {
		dep := depResolver(data)
		var resolved Graph
		resolved, err = dep.Resolve()
		if err != nil {
			log.Errorf("Failed to resolve dependencies: %s", err)
			displayDependencyGraph("circular dependency graph", resolved, log.Error)
		} else {
			log.Debugf("The dependency graph resolved successfully")
			displayDependencyGraph("resolved dependency graph", resolved, log.Debug)
			for _, item := range resolved {
				if item.index >= 0 {
					result = append(result, data[item.index])
				}
			}
		}
	}
	return
}
Resolve resolve dependencies
package depends
import (
	"hidevops.io/hiboot/pkg/factory"
	"hidevops.io/hiboot/pkg/log"
	"hidevops.io/hiboot/pkg/system/types"
	"hidevops.io/hiboot/pkg/utils/str"
	"reflect"
)
type depResolver []*factory.MetaData
func (s depResolver) Resolve() (resolved Graph, err error) {
	var workingGraph Graph
	var node *Node
	for i, item := range s {
		dep, ok := s.findDependencies(item)
		if ok {
			node = NewNode(i, item, dep...)
		} else {
			node = NewNode(i, item)
		}
		workingGraph = append(workingGraph, node)
	}
	resolved, err = resolveGraph(workingGraph)
	return
}
func (s depResolver) findDependencyIndex(depName string) int {
	for i, item := range s {
		if item.TypeName == depName {
			return i
		}
		if item.ShortName == depName || item.Name == depName || item.PkgName == depName {
			return i
		}
		if item.Kind == types.Method {
			method := item.MetaObject.(reflect.Method)
			methodName := str.ToLowerCamel(method.Name)
			if depName == methodName || depName == item.PkgName+"."+methodName {
				return i
			}
		}
	}
	return -1
}
func (s depResolver) findDependencies(item *factory.MetaData) (dep []*Node, ok bool) {
	if len(item.DepNames) > 0 {
		for _, dp := range item.DepNames {
			depIdx := s.findDependencyIndex(dp)
			if depIdx >= 0 {
				depMetaData := s[depIdx]
				item.DepMetaData = append(item.DepMetaData, depMetaData)
				dep = append(dep, NewNode(depIdx, depMetaData))
			} else {
				extData := &factory.MetaData{Name: dp}
				item.DepMetaData = append(item.DepMetaData, extData)
				dep = append(dep, NewNode(depIdx, extData))
				log.Warnf("dependency %v is not found", dp)
			}
		}
		ok = true
	}
	return
}