I am new to go programming language.
I am using below to packages in my my-s3zipper.go program.
"github.com/AdRoll/goamz/aws"
"github.com/AdRoll/goamz/s3"
When I run my go program with local user, its running fine. Below is the go run command.
go run my-s3zipper.go
Running on port 80
When I run my go program with sudo, its not running and throwing errors. Below is the go run command using sudo.
sudo go run my-s3zipper.go
my-s3zipper.go:19:5: cannot find package "github.com/AdRoll/goamz/aws" in any of:
/usr/lib/golang/src/github.com/AdRoll/goamz/aws (from $GOROOT)
/root/go/src/github.com/AdRoll/goamz/aws (from $GOPATH)
my-s3zipper.go:20:5: cannot find package "github.com/AdRoll/goamz/s3" in any of:
/usr/lib/golang/src/github.com/AdRoll/goamz/s3 (from $GOROOT)
/root/go/src/github.com/AdRoll/goamz/s3 (from $GOPATH)
my-s3zipper.go:21:5: cannot find package "github.com/garyburd/redigo/redis" in any of:
/usr/lib/golang/src/github.com/garyburd/redigo/redis (from $GOROOT)
/root/go/src/github.com/garyburd/redigo/redis (from $GOPATH)
Any one can help me resolving this?
Thanks
Try:
sudo GOPATH="$GOPATH:/your/home/go/path" go run my-s3zipper.go
or
su
GOPATH="$GOPATH:/your/home/go/path"
go run my-s3zipper.go
The reason, probably, is that the GOPATH variable is different for your user and root.
You can detect /your/home/go/path
by executing echo $GOPATH
when you logged in your user
This will probably work
sudo -E go run my-s3zipper.go
From the sudo man page
-E' The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the -E option is specified and the user does not have permission to preserve the environment.