请使用golang osStat
import ( "fmt" "os" )
func main() { filePath := "path/to/file.txt"
fileInfo, err := os.Stat(filePath)
if err != nil {
fmt.Println("Error occurred:", err)
return
}
fmt.Println("File name:", fileInfo.Name())
fmt.Println("Size in bytes:", fileInfo.Size())
fmt.Println("Permissions:", fileInfo.Mode())
fmt.Println("Last modified:", fileInfo.ModTime())
fmt.Println("Is directory:", fileInfo.IsDir())
}
原文地址: http://www.cveoy.top/t/topic/h3BS 著作权归作者所有。请勿转载和采集!