example how to check write access to file
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Fprintf(os.Stderr, "usage: access <path>\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
filename := os.Args[1]
|
||||
if err := unix.Access(filename, unix.W_OK); err != nil {
|
||||
fmt.Printf("%v: %v\n", filename, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user