Changing file permissions
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access