-3

The title is the problem - here is a brief explanation as to how I got here as I imagine that may help with sleuthing.

I installed go, and everything was fine. I ran build essential golang command on Ubuntu, and all of a sudden my go version was out of sync with my /usr/local/go/src/VERSION file.

I deleted my go files at /usr/local/go/, as well as the go and the go-1.8 folders in /usr/bin/. I then reinstalled go at /usr/local/go

Now, when I run go env as a user, the output looks correct. However (the title), when I am sudo, no go commands are recognized and I get the following message: The program 'go' can be found in the following packages: * golang-go * gccgo-go

As a user, some of my go env output is:

GOPATH="/home/{me}/go"
GOROOT="/usr/local/go"

As a user, my echo $PATH is :

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/{me}/go/bin

My ~/.profile includes:

export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Help, please? : )

Senura Dissanayake
  • 654
  • 1
  • 9
  • 29
kbar
  • 77
  • 1
  • 9
  • This question directly involves a tool used primarily for programming, the Go programming language compiler and tools. It's on-topic. – peterSO Apr 24 '18 at 04:08
  • 1
    `sudo su - root` then `Go` dissappears from my system too..Maybe the PATH is not set for `root` – Nidhin David Apr 24 '18 at 06:12

1 Answers1

1

You should ask in another community, like: unix & linux

But, the problem is that when you log as root, the PATH variable is set as configured for root user. you have to configure the PATH environment variable of root user, or run su/sudo as following:

su --preserve-environment -
sudo --preserve-env bash
Pablo
  • 37
  • 5