英文:
Go build is giving permission denied error on mac
问题
我正在尝试运行go build
命令,但是遇到了以下错误:go run
命令可以正常运行。
open /Users/an../Library/Caches/go-build/32/3284dc1dfe0121246372cec7d0efeba47a547120b3fa696ef6283422d69cd994-a: permission denied
英文:
I am trying to run go build
and seeing the following error. go run
works fine
open /Users/an../Library/Caches/go-build/32/3284dc1dfe0121246372cec7d0efeba47a547120b3fa696ef6283422d69cd994-a: permission denied
答案1
得分: 1
你遇到的错误可能是由于Go构建缓存目录的权限问题引起的。当你运行go build时,Go会尝试将编译的目标文件写入缓存目录,以便于将来更快地进行构建。然而,似乎Go没有足够的权限写入缓存目录,因此出现了"permission denied"错误。
请确保你有适当的权限写入缓存目录。你可以使用ls命令检查缓存目录的权限和所有权:
ls -ld /Users/an../Library/Caches/go-build
如果你对该目录没有写入权限,你可以将所有权更改为你的用户:
sudo chown -R $(whoami) /Users/an../Library/Caches/go-build
英文:
The error you are encountering is likely due to a permissions issue with the Go build cache directory. When you run go build, Go will try to write the compiled object files to the cache directory for faster future builds. However, it seems that Go doesn't have the necessary permissions to write to the cache directory, hence the "permission denied" error.
Ensure that you have the appropriate permissions to write to the cache directory. You can use the ls command to check the permissions and ownership of the cache directory:
ls -ld /Users/an../Library/Caches/go-build
If you don't have write permissions on this directory, you can change the ownership to your user:
sudo chown -R $(whoami) /Users/an../Library/Caches/go-build
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论