I am simply reading the /proc/diskstats
file. My code is:
func ReadFromFile(filepath string)(string){
defer func() {
if err1 := recover(); err1 != nil {
fmt.Println("!!!!!!!!!!!!!!!!Panic Occured and Recovered in readFromFile(), Error Info: ", err1)
}
}()
strData := ""
data, err := ioutil.ReadFile(filepath)
if err != nil{
fmt.Println("File read error: ", err)
return ""
}
strData = string(data)
return strData
}
The error I am getting is:
File read error: open /proc/diskstats: too many open files
Not only for this file, I am also getting the same error for some other files.
I have also run this command:
root@golang:~# lsof|wc -l
785
Please guide me.