detectEffectVersionUncached performs the actual version detection logic.
()
| 54 | |
| 55 | // detectEffectVersionUncached performs the actual version detection logic. |
| 56 | func (tp *TypeParser) detectEffectVersionUncached() EffectMajorVersion { |
| 57 | packages := tp.DiscoverPackages() |
| 58 | |
| 59 | var detected EffectMajorVersion |
| 60 | found := false |
| 61 | |
| 62 | for _, pkg := range packages { |
| 63 | if pkg.Name != "effect" { |
| 64 | continue |
| 65 | } |
| 66 | |
| 67 | var major EffectMajorVersion |
| 68 | switch { |
| 69 | case pkg.Version == nil: |
| 70 | major = EffectMajorUnknown |
| 71 | case len(*pkg.Version) > 0: |
| 72 | switch (*pkg.Version)[0] { |
| 73 | case '3': |
| 74 | major = EffectMajorV3 |
| 75 | case '4': |
| 76 | major = EffectMajorV4 |
| 77 | default: |
| 78 | major = EffectMajorUnknown |
| 79 | } |
| 80 | default: |
| 81 | major = EffectMajorUnknown |
| 82 | } |
| 83 | |
| 84 | if !found { |
| 85 | detected = major |
| 86 | found = true |
| 87 | } else if detected != major { |
| 88 | return EffectMajorUnknown |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | if !found { |
| 93 | return EffectMajorUnknown |
| 94 | } |
| 95 | return detected |
| 96 | } |
| 97 | |
| 98 | // SupportedEffectVersion returns the normalized supported Effect major version. |
| 99 | // It returns EffectMajorV4 when v4 is detected, and EffectMajorV3 for all other |
no test coverage detected