In this program, we will set file permission with the help of os.Chmod() function and print file permission using Mode() function on the console screen.
In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt, os packages then we can use a function related to the fmt and os package.
In the main() function, we assigned permission to the file using os.Chmod() function. Here, we printed file permission before and after changing the permission of the file.
Program/Source Code:
The source code to set file permission is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt, os packages then we can use a function related to the fmt and os package.
In the main() function, we assigned permission to the file using os.Chmod() function. Here, we printed file permission before and after changing the permission of the file.
need an explanation for this answer? contact us directly to get an explanation for this answer