1

I have installed Go1.14.3 on my remote server which is on a private network. When I remote SSH my VS Code to that server to work on my Go Project located at ~/BBS/r1rm/tools/DSMigrateWeb, I can see Go1.14.3 in the VS Code taskbar. Even when I run go command from "VS Code terminal", it executes and shows the desired output.

jaydev1642@linuxjaydev:~/BBS/r1rm/tools/DSMigrateWeb$ go
Go is a tool for managing Go source code.

Then when I migrate to a different directory in "VS Code terminal" itself and run the go command, then too it works fine but do the same on command line for any directory and I get the error as "Command 'go' not found".

jaydev1642@linuxjaydev:~/BBS/r1rm/tools/DSMigrateWeb$ go

Command 'go' not found, but can be installed with:

sudo snap install go # version 1.20.6, or sudo apt install golang-go # version 2:1.13~1ubuntu2 sudo apt install gccgo-go # version 2:1.13~1ubuntu2

See 'snap info go' for additional versions.

Here is my .profile file containing GOROOT and PATH variables:

export GOROOT=/usr/local/go

export GOPATH=usr/local/go/bin:/home/jaydev1642/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin: /bin:/usr/games:/usr/local/games

I am not sure why I am facing this issue where Go exists if I try to access it from VS Code Terminal but doesn't when I do from command line. I also restarted the server just in case that might help but it doesn't.

  • That profile is loaded by VS Code because you're working on a Go project. It won't be loaded in a normal terminal window. Only commands in folders in PATH (not GOPATH) can be executed in normal terminals – Panagiotis Kanavos Jul 20 '23 at 08:32
  • I'm not pretty much sure about this but the following worked for me, export GOPATH=$HOME/go //go refers to my folder location export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin I have added these in my .profile file and restarted the server. Hope this helps. – rohit Jul 20 '23 at 10:19
  • You should never need to set `GOROOT`, and it is very unlikely you need to set `GOPATH`. Not to mention `GOPATH` is not a list of directories to search for commands. You presumably meant to `export PATH=...`. – Kurtis Rader Jul 20 '23 at 21:16

0 Answers0