Command ‘go’ not found, but can be installed with:
So you just installed Go on Linux huh?
This means you probably set the environmental variable via the command line which is temporary. Don’t install go this way. You could do as the documentation says and add the following to a file:
However if you look in that file it has some important looking code in it. This is because it is a script.
It felt dirty to place the above code in that file so I did some research and found a better alternative. You simply create a new file in the /etc/profile.d directory and place the above export line of code in it and save it. You can name the file anything and add .sh to it and it will be found and loaded. Then you logout and back in like the documentation suggests and open a terminal and type “go version” and it works properly.
See my go_profile.sh file :
Doing it this way instead of adding it to the ~.profile file is better because it reduces the chance of messing up the code in a file. The script actually reads all of the files in the profile.d folder and this is why it works. For more information see this article in the section “Persistent environment variables”. You can do any other environmental variables you need set this way too.
Another reason for this error is you need to logout of your Linux computer then log back in or restart/reboot the system. The variables are read and set at login time or reboot/restart.