MCPcopy Create free account
hub / github.com/ethereum/node-crawler / parseVersion

Function parseVersion

pkg/vparser/vparser.go:99–138  ·  view source on GitHub ↗
(input string)

Source from the content-addressed store, hash-verified

97}
98
99func parseVersion(input string) Version {
100 var vers Version
101 split := strings.Split(input, "-")
102 split_length := len(split)
103 switch len(split) {
104 case 8:
105 fallthrough
106 case 7:
107 fallthrough
108 case 6:
109 fallthrough
110 case 5:
111 vers.Date = split[split_length-1]
112 vers.Build = split[split_length-2]
113 vers.Tag = strings.Join(split[1:split_length-3], "")
114 vers.Major, vers.Minor, vers.Patch = parseVersionNumber(split[0])
115 case 4:
116 // Date
117 vers.Date = split[3]
118 fallthrough
119 case 3:
120 // Build
121 vers.Build = split[2]
122 fallthrough
123 case 2:
124 // Tag
125 vers.Tag = split[1]
126 fallthrough
127 case 1:
128 // Version
129 vers.Major, vers.Minor, vers.Patch = parseVersionNumber(split[0])
130 }
131
132 if vers.Major == 0 && vers.Minor == 0 && vers.Patch == 0 {
133 fmt.Println("Version string is invalid:", input)
134 vers.Error = true
135 }
136
137 return vers
138}
139
140func parseVersionNumber(input string) (int, int, int) {
141 // Version

Callers 1

ParseVersionStringFunction · 0.70

Calls 1

parseVersionNumberFunction · 0.85

Tested by

no test coverage detected