go - 什么是 shell 中 test -x 的 golang 等价物?
问题描述
https://stackoverflow.com/a/60128480/293195IsExecOwner(file string)
中的答案解决了该主题,但我不确定这是否等同于 POSIX Shell?如果用户在该文件的组中并且该组设置了可执行位,则此解决方案可能不正确。test -x
解决方案
它是
func Access(path string, mode uint32) (err error)
在https://godoc.org/golang.org/x/sys/unix#Access
with mode := X_OK
Referenz: https://linux.die.net/man/2/access
推荐阅读
- python - 使用python中的分割从图像中提取特定区域
- jquery - JQuery - 将数组元素设置为每个属性值
- amazon-web-services - 快照大小如何影响 Amazon Redshift 中的还原过程?
- python - 我正在尝试从网站中提取特定表格,但我在执行此操作时遇到问题
- java - 运行 apksigner verify 时出错
- python - Python:添加由前一个键中的单词组成的新字典键
- ruby-on-rails - 带有外部授权和回调的 Rails before_action
- python - 从满足条件的熊猫列中提取属性[按频率排序]
- c - 可以在一行中声明/分配一个 int* 吗?
- reactjs - NEXT JS - 如何删除查询参数