Golang io/ioutil.ReadDir() function example
package io/ioutil
Golang io/ioutil.ReadDir() function usage example
package main
import (
"fmt"
"io/ioutil"
)
func main() {
readerDir, err := ioutil.ReadDir("/")
for _, fileInfo := range readerDir {
fmt.Printf("\n File Name : %s \n", fileInfo.Name())
fmt.Printf("\n File Is Directory? : %v \n", fileInfo.IsDir())
fmt.Printf("\n File Size : %s \n", fileInfo.Size())
fmt.Printf("\n File Last Modified Time : %s \n", fileInfo.ModTime())
fmt.Printf("\n File Permission : %s \n", fileInfo.Mode())
fmt.Println("----------------")
}
fmt.Println("Error : ", err)
}
Reference :
Advertisement
Something interesting
Tutorials
+11.7k Golang : Gorilla web tool kit secure cookie example
+16.4k Golang : How to implement two-factor authentication?
+7.3k Golang : How to iterate a slice without using for loop?
+13.6k Android Studio : Password input and reveal password example
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+29.5k Golang : Saving(serializing) and reading file with GOB
+11.2k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+14.4k Golang : How to filter a map's elements for faster lookup
+14.2k Golang : Convert IP version 6 address to integer or decimal number
+5.6k PHP : Convert CSV to JSON with YQL example
+27.5k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+7.9k Javascript : How to check a browser's Do Not Track status?