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
374 stars 26 forks source link

Allow specifying arch - especially for darwin #71

Closed kishansairam9 closed 1 year ago

kishansairam9 commented 1 year ago

Having functionality to specify arch would be great to have. Sometimes projects might be dependent on x86_64 binaries Something like -

$ gobrew install 1.19@darwin-amd64
[Info] Downloading version: 1.19@darwin-amd64
[Info] Downloading from: https://go.dev/dl/go1.19@darwin-amd64.darwin-arm64.tar.gz # FAIL 
[Info]: Downloading version failed: https://go.dev/dl/go1.19@darwin-amd64.darwin-arm64.tar.gz returned status code 404
[Error]: Please check connectivity to url: https://go.dev/dl/go1.19@darwin-amd64.darwin-arm64.tar.gz
kevincobain2000 commented 1 year ago

Interesting….

kevincobain2000 commented 1 year ago

Item 1

Probably 1.19@darwin-amd64 is not a good idea. Following could be better

gobrew install 1.19 darwin-amd64

We currently use @ for 1.19@latest and 1.19@dev-latest

Item 2

I also wonder if you can set envs as GOOS=darwin GOARCH=amd64 gobrew install 1.19, as currently there is a method that uses runtime vars

https://github.com/kevincobain2000/gobrew/blob/4328ce1176bbb83904e650f8bf815e7600a49fc0/gobrew.go#L85-L87

kishansairam9 commented 1 year ago

Item 1 is ideal. With item 2 does gobrew support having 1.19 amd and also arm?

kevincobain2000 commented 1 year ago

well, it is not a gobrew thing. It autodetects what arch you are currently on and fetches the go binary for that. I still wonder why would you need to specify the arch that is different than your current OS

kishansairam9 commented 1 year ago

One of the projects use https://github.com/rubrikinc/go-pcre as a dependency, when I tried to run it on arm build it fails with arch mismatch. The same would run on amd64 build

kevincobain2000 commented 1 year ago

hmmm okay. In such a case, probably we should consider a lot more changes to it, than simply allowing to install the desired go (with arch).

A few changes I can quickly thing could be as below:

  1. Provide a hint about arch when done gobrew ls
  2. And need to think about what happens when a user wants different arcs but the same version