package ws import ( "fmt" "os" ) func checkFile(fileNa string) error { var ( err error stat os.FileInfo ) if stat, err = os.Stat(fileNa); err != nil { return fmt.Errorf("unable to check metadata for file '%s': %v", fileNa, err) } if !stat.Mode().IsRegular() { return fmt.Errorf("file '%s' is not regular") } if stat.Mode()&0444 == 0 { return fmt.Errorf("file '%s' is not readable") } return nil }