Skip to content

Commit

Permalink
Fix: add log (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceLiZhixin authored Sep 9, 2022
1 parent 8626823 commit 9e573bd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions autowire/sdid_parser/sdid_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ func (p *defaultSDIDParser) Parse(fi *autowire.FieldInfo) (string, error) {
// is interface field without valid sdid from tag value, and with 'IOCInterface' suffix
// load trim suffix as sdid
injectStructName = strings.TrimSuffix(fi.FieldType, "IOCInterface")
} else if bestMatchSDIDs, matchProfile, err := autowire.GetBestImplementMapping(fi.FieldType, config.GetActiveProfiles()); err == nil {
// is interface field without valid sdid from tag value, without 'IOCInterface' suffix
// load injectStructName from implements annotation mapping
injectStructName = bestMatchSDIDs[0]
if len(bestMatchSDIDs) > 1 {
logger.Red("[Autowire Default SDIDParser] Field %s has multi impls [%+v] under profile %s, select first one.", fi.FieldType, bestMatchSDIDs, matchProfile)
} else if !util.IsPointerField(fi.FieldReflectType) {
// is custom interface field, try to get best implements
if bestMatchSDIDs, matchProfile, err := autowire.GetBestImplementMapping(fi.FieldType, config.GetActiveProfiles()); err == nil {
// is interface field without valid sdid from tag value, without 'IOCInterface' suffix
// load injectStructName from implements annotation mapping
injectStructName = bestMatchSDIDs[0]
if len(bestMatchSDIDs) > 1 {
logger.Red("[Autowire Default SDIDParser] Field %s has multi impls [%+v] under profile %s, select first one.", fi.FieldType, bestMatchSDIDs, matchProfile)
}
}
}
return autowire.GetSDIDByAliasIfNecessary(injectStructName), nil
Expand Down

0 comments on commit 9e573bd

Please sign in to comment.