Answer the question
In order to leave comments, you need to log in
What could be the problem with permissions when trying to compile golang?
I ask for advice on the following situation.
I installed a linux mint virtual machine, installed golang in it.
When trying to compile and other commands without root, an error occurs that there are not enough rights. And when you try to execute the same commands under sudo, an error occurs that the "go" command is unknown:
[email protected]:/home/work/src$ go mod init mm
go: creating new go.mod: module mm
go: updating go.mod: open /home/work/src/go.mod: permission denied
[email protected]:/home/work/src$ sudo go mod init mm
sudo: go: command not found
[email protected]:/home/work/src$ go build
go build _/home/work/src: copying /tmp/go-build4142243374/b001/exe/a.out: open src: permission denied
[email protected]:/home/work/src$ sudo go build
sudo: go: command not found
Answer the question
In order to leave comments, you need to log in
You need to understand the rights.
If you want it to be collected from your user, not under root, then
you need to make sure that you are the owner of the project folder, you can do it like this sudo chown -R ваш_логин /home/work/src
and set the correct permissions on the /tmp folder chmod 777 /tmp
Under root, it doesn’t find go because its binaries are not in PATH, you need to do something like this
But you first need to find where you have Go.
It is possible under a normal user, where Go finds to execute , the answer can be /usr/lib/golang/bin/go - then you need to register as I wrote.
If it does not work - write, I will try to help. export PATH=$PATH:/usr/lib/golang/bin
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question