zekroTJA / goup

🚀 Like rustup or nvm/fnm but for Go: A simple version manager for Go written in Rust!
MIT License
7 stars 1 forks source link

Add fallback for upstream version fetching #1

Closed zekroTJA closed 1 year ago

zekroTJA commented 1 year ago

Currently, the upstream version fetching relies on the git ls-remote command. There should be a fallback in place when git is not available on the system which queries tags via the GitHub Rest API.

zekroTJA commented 1 year ago

Well, fetching the list of tags via the REST API is actually way faster than using git ls-remote --tags. So, the default behavior will be the REST API request and git ls-remote --tags will be used as fallback if the API request fails.

Here you can see the results of benchmarking goup lsr using hyperfine with 3 warmup runs and 20 benchmark runs.

Command Mean [ms] Min [ms] Max [ms] Relative
lsr (git ls-remote --tags) 372.5 ± 25.8 345.9 469.2 1.00
lsr (GitHub API) 73.9 ± 77.3 38.3 335.3 1.00
lsr (GitHub API + git fallback) 71.9 ± 70.5 38.6 292.3 1.00