由于我是Go语言的新手,我试图在终端执行我的第一个Go代码,因为代码会编译并提供输出,但是我收到了初始化失败的错误
As I am new to Go, I am trying to execute my first Go code with terminal, as the code compiles and gives an output, But I am getting an error of initialization failure
go: disabling cache (/home/myname/.cache/go-build) due to initialization failure: open /home/myname/.cache/go-build/log.txt: permission denied我该如何解决?
推荐答案您面临的错误是您没有足够的权限在要尝试使用的目录中创建/删除/修改.
The error you are facing is that you don't have enough privileges to create/delete/modify inside the directory you are trying to work in.
如何解决?
-
简单方法:您可以通过使用 chmod 命令更改正在处理的目录的权限来解决此问题,例如: sudo chmod -R 777/testDir .使用此功能,您可以允许所有者-组-其他用户创建,删除和修改目录+子目录(使用 -R 时).因此,我建议您暂时进行 sudo chmod -R 754/testDir .
The easy way: You can solve this problem by changing the permissions of the directory you are working on by using the chmod command, for example: sudo chmod -R 777 /testDir. Using this you are allowing the owner - group - others to create, delete, and modify the directory + the sub directories (when -R is used). So i suggest you do sudo chmod -R 754 /testDir for now.
不太容易的方法:可以使用 chown ,这意味着更改所有者和组的目录所有权,例如 sudo chown -R newOwner:newGroup/testDir ,这样您就拥有目录+子目录的最终所有权.
The less easy way: You can use chown which means changing the ownership for the directory for both the owner and the group, for example sudo chown -R newOwner:newGroup /testDir and by that you have the ultimate ownership for the directory + the sub directories.
最简单但最危险的方法:您可以以 root 的身份在目录中工作,并根据自己的喜好进行操作,当打开终端时,请使用命令 sudo-s 并输入密码成为root用户.不推荐,因为如果使用不正确,它会破坏系统文件!在此处查看风险为什么以root用户身份登录很糟糕?
The most easy yet a dangerous way: You can work in the directories as a root and do what ever you like, when you open up the terminal use the command sudo -s and enter your password to be a root user. Not Recommended because it can destroy system files if you used it wrong! see the risks here Why is it bad to log in as root?
更多推荐
“权限被拒绝";初始化过程中发生错误
发布评论