kevincobain2000 / gobrew

Go version manager, written in Go. Super simple tool to install and manage Go versions. Install go without root. Gobrew doesn't require shell rehash.
https://medium.com/web-developer/go-version-manager-gobrew-c8750157dfe6
MIT License
364 stars 24 forks source link

judgeVersion panic when GITHUB_TOKEN env is set to an invalid token #138

Closed beppler closed 11 months ago

beppler commented 11 months ago

I had an invalid GITHUB_TOKEN set on my account and this caused gobrew.ListRemoteVersions to return an empty list of versions.

Because the list is empty the code on gobrew.judgeVersion generates an panic as can be seen on the image bellow.

image

This PR contains a fix for the panic error.

Probably it is the same error reported on #135.

kevincobain2000 commented 11 months ago

Hmmm. I think we should just get rid of GitHub token completely and obtain the latest version from the raw.githubusercontent too like it is done for ls-remote on the branch:json

basically not rely on git tags at all.

juev commented 11 months ago

Hmmm. I think we should just get rid of GitHub token completely and obtain the latest version from the raw.githubusercontent too like it is done for ls-remote on the branch:json

We use tags in two places:

  1. for the go/golang repository
  2. for the gobrew repository to get the latest version

And if for Golang we can use json from a separate branch, then for gobrew I do not yet understand what can be used.

And so it's a great idea, we need to think about it in more detail.

kevincobain2000 commented 11 months ago

Hmmm. I think we should just get rid of GitHub token completely and obtain the latest version from the raw.githubusercontent too like it is done for ls-remote on the branch:json

We use tags in two places:

for the go/golang repository for the gobrew repository to get the latest version And if for Golang we can use json from a separate branch, then for gobrew I do not yet understand what can be used.

And so it's a great idea, we need to think about it in more detail.

I think we can just create a new branch called version, and in the release.yml, after goreleaser has done making the release, push current gobrew version to version.txt file on branch:version. Which can then be used via raw.githubusercontent when gobrew wants to check it's own version.

I don't think there is an industry standard right now that we can follow, all we need is to get the current version somewhere from the internet, and raw.githubusercontent is a rate limit safe place to put it.

PS: In npm we can just refer to the package.json but not in GO

beppler commented 11 months ago

Hey guys, can I close this one as #140 fixes it in another way?

juev commented 11 months ago

Hey guys, can I close this one as #140 fixes it in another way?

I think so, thank you!