dongzhouji4021 2019-06-03 20:55
浏览 950
已采纳

golang将os.ModePerm转换为字符串

I would like to have as a string the permissions representation of a file. Here is what I want to do :

fileInfo, err := os.Lstat(path)
fileMode := fileInfo.Mode()
// fileMode.String() gives dturwxrwxrwx or -rwxrwxrwx
// which i do not want because the size is not always the same
unixPerms := fileMode & os.ModePerm

I get -rwxrwxrwx for both cases, which is close to what i am looking for.

However, the returned object is of type os.FileMode. How can I then convert it into a string?

  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 提问应符合社区要求 12月14日

      悬赏问题

      • ¥15 香农解码的代码问题,无法输出解码结果
      • ¥15 Python操作注册表
      • ¥45 入门级别的一段VUE前端拍照像后端发送请求的代码,帮排错
      • ¥15 anaconda打开spyder后一直闪退,不知道怎么办
      • ¥15 解决迷宫问题中无法运行的问题
      • ¥15 关于aspnetcore中使用mqttnet库的entire
      • ¥15 关于#python#的问题,请各位专家解答!
      • ¥100 关于远控软件的两个问题
      • ¥15 基于STM32的AD8232心电采集装置设计
      • ¥15 我在wordpress里安装Ultimate menber 插件之后进行测试,点击注册之后发现网页打不了