Golang’s method of judging whether a file can be written:
The judgment code is as follows:
err := syscall.Access(file, syscall.O_RDWR) if err != nil { fmt.Println(err.Error()) } else { fmt.Println("access ok") }
Only syscall.Access needs to pass in the file and permission code, that is, whether it is allowed or not.
For more golang knowledge, please pay attention to the golang tutorial column on the PHP Chinese website.
The above is the detailed content of How to determine whether a file can be written in Golang. For more information, please follow other related articles on the PHP Chinese website!