MCPcopy Index your code
hub / github.com/larksuite/cli / fetchLatestVersion

Function fetchLatestVersion

internal/update/update.go:205–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

203}
204
205func fetchLatestVersion() (string, error) {
206 resp, err := httpClient().Get(registryURL)
207 if err != nil {
208 return "", err
209 }
210 defer resp.Body.Close()
211
212 if resp.StatusCode != http.StatusOK {
213 return "", fmt.Errorf("npm registry: HTTP %d", resp.StatusCode)
214 }
215
216 body, err := io.ReadAll(io.LimitReader(resp.Body, maxBody))
217 if err != nil {
218 return "", err
219 }
220
221 var result npmLatestResponse
222 if err := json.Unmarshal(body, &result); err != nil {
223 return "", err
224 }
225 if result.Version == "" {
226 return "", fmt.Errorf("npm registry: empty version")
227 }
228 return result.Version, nil
229}
230
231// --- semver helpers ---
232

Callers 2

RefreshCacheFunction · 0.85
FetchLatestFunction · 0.85

Calls 3

httpClientFunction · 0.85
GetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected