Changing the permission of a file so that you can access it later from a lower-privileged user may also be useful. This example demonstrates how to change file permissions using the os package. You can change file permissions easily using the os.Chmod() function.
This program is named chmode.go so that it does not conflict with the default chmod program provided on most systems. It has the same basic functionality as chmod, but without any extra features.
The os.Chmod() function is straightforward, but it must be provided an os.FileMode type. The os.FileMode type is simply a uint32 type so that you can provide it a uint32 literal (a hardcoded number) or you will have to ensure that the file mode value you provide is casted to an os.FileMode type. In this example, we will take the string value provided from the command line (for example, "777"...