New Go user... GOPATH/src error message

Hi all,

I am in the spin cycle. I am getting a lot of answers when searching this error message:

Use “dep help [command]” for more information about a command.
[root@ip-10-0-132-251 bin]# ./dep ensure
root project import: /root/go/bin is not within any GOPATH/src

My dep file is located within a /root/go/bin/ directory

1 Like

Please do not be root when doing anything. You should stay as your user as long as possible and never ever login as root. Use sudo for single commands when necessary and only if you understand what they do and how they will affect your system.

Other than that, source code of your programs has to be in $GOPATH/src not $GOPATH/bin.


So should I log out as root and create the $GOPATH/src directory? I ran go env and my go path is now /home/ec2-user/go .

When i try to navigate to that dir via cli, it gives me “no such file or dir”

1 Like

Is ec2-user your username?

But of course you need to create that folder if it’s isn’t there. Go won’t create it on installation for all users as only a fraction of users in a multiuser system actually might use go.

1 Like

Yes… ec2-user is the user name. I am connected via putty to a RHEL 7 terminal running on an aws ec2 instance.

1 Like

Learn Linux first, then go, then aws. Then deploy your application.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.