首页 > 解决方案 > 什么是 shell 中 test -x 的 golang 等价物?

问题描述

https://stackoverflow.com/a/60128480/293195IsExecOwner(file string)中的答案解决了该主题,但我不确定这是否等同于 POSIX Shell?如果用户在该文件的组中并且该组设置了可执行位,则此解决方案可能不正确。test -x

是否需要咨询https://godoc.org/golang.org/x/sys/unix

标签: go

解决方案


它是

func Access(path string, mode uint32) (err error)

https://godoc.org/golang.org/x/sys/unix#Access with mode := X_OKReferenz: https://linux.die.net/man/2/access


推荐阅读