Golang net/http.Dir type and Dir.Open() function example
package net/http
Golang net/http.Dir type and Dir.Open() function usage example
package main
import (
"fmt"
"net/http"
)
func main() {
var directory http.Dir
directory = "./"
file, err := directory.Open("input.txt")
if err != nil {
panic(file)
}
fileInfo, _ := file.Stat()
fmt.Println(fileInfo.Name())
fmt.Println("Size : ", fileInfo.Size())
}
Output :
input.txt
Size : 22
References :
Advertisement
Something interesting
Tutorials
+9.6k Javascript : Read/parse JSON data from HTTP response
+17k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+15.6k Golang : Validate hostname
+4.6k MariaDB/MySQL : How to get version information
+26.7k Golang : How to check if a connection to database is still alive ?
+21.8k Golang : Convert string slice to struct and access with reflect example
+9.4k Golang : Create unique title slugs example
+15.3k nginx: [emerg] unknown directive "ssl"
+17.6k Golang : delete and modify XML file content
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+6.2k Golang : Extract XML attribute data with attr field tag example
+19.2k Golang : Check if directory exist and create if does not exist