New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I am removing Go, I want to prefer existing paths #24
Conversation
I see various issues with the way the As mentioned on the
Most likely there should (at least) be a confirmation step before |
@martinkunc Thanks for the PR, I'll review it as soon as I can. @d2s Can you point me to where is the convention about storing code under Regardless, I guess it doesn't hurt printing out the full path and asking for another confirmation. |
@canha Probably my misunderstanding, sorry. At least that is what I had understood while following Go's official documentation (How to Write Go Code - The Go Programming Language) and reading how Google etc. use Go.
From a blog post The default GOPATH (from 2016):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for thinking about this case. What happens if for some reason the go
executable is not in the path? I believe the variables will be empty and we aren't doing additional checks. We should probably do something about this.
How were you calling go from your terminal if you didnt have a GOROOT? |
Because you only need |
What about a check like this ? I guess some future improvement would be to try to use /usr/local/go over ~/.go when possible. |
rm -rf "$GOROOT" | ||
# Try $GOROOT var, then if go is in PATH, execute go env GOROOT to get configured value, otherwise will be empty | ||
GOROOT=$( [ ! -z "$GOROOT" ] && echo \"$GOROOT\" || ( command -v go > /dev/null && go env GOROOT) ) | ||
GOPATH=$(go env GOPATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If $GOROOT is still empty at this point (line 49), what do you think about just showing an error and exiting the script immediately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks in testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, sorry unfortunatelly notifications from GH seems to be slow for me.
Can you explain more how it breaks @majorthorn ? Would you like to cover the case when GOROOT is not set ? Because this script is setting it on install. Or some other case when someone used script just for uninstallation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with that is that it requires root privileges, which is something we'd like to avoid. |
|
This is 7 months old. Suggesting we close this pr |
The script wasnt removing Go for me, because I havent had $GOROOT or it wasnt in ~/.go
I think when we are removing, we could rely on what go env has set. What do you think about following changes ?
Btw, great script :)