file, err := os.Stat("test.txt") if err != nil { log.Fatal(err) } mode := file.Mode() fmt.Printf("File mode: %o\n", mode.Perm())
file, err := os.Stat("test.txt") if err != nil { log.Fatal(err) } if mode := file.Mode(); mode.IsRegular() { fmt.Println("test.txt is a regular file") }This code uses os.Stat to get the information about the file "test.txt". The Mode method is called to check if the file is a regular file using the IsRegular method. These examples are part of the Go standard library and are included in the os package.