September 2017
Intermediate to advanced
466 pages
9h 33m
English
There are times that we need to find detailed information about the Unix permissions of a file. The filePerm.go Go utility will teach you how to read the Unix file permissions of a file or a directory and print them as a binary number, a decimal number, and a string. The program will be presented in three parts. The first part is the following:
package main import ( "fmt" "os" "path/filepath" )
The second part is as follows:
func tripletToBinary(triplet string) string { if triplet == "rwx" { return "111" } if triplet == "-wx" { return "011" } if triplet == "--x" { return "001" } if triplet == "---" { return "000" } if triplet == "r-x" { return "101" } if triplet == "r--" { return "100" } if triplet == "--x" { return ...Read now
Unlock full access