example:
package main
import (
"fmt"
"io/ioutil"
)
func main() {
dirname := "/root/test"
dir, _ := ioutil.ReadDir(dirname)
if len(dir) == 0 {
fmt.Println(dirname + " is empty dir!")
} else {
fmt.Println(dirname + " is not empty dir!")
}
}
Read More:
- Golang gets the list of files under the folder
- Solve the problem of “error empty block statement no empty” in the console (Vue project)
- When using freemaker template to get values, an error is reported when the attribute is empty
- Determine whether the list is empty isempty
- The background object of thymeleaf is null, which solves the problem of error when the object is empty to get the property value
- Adding project folder in SourceInsight is empty
- Golang timer function executes a function every few minutes
- How to compare the equality of structures in golang
- How to get all the keys of map by golang
- Mac bigsur cannot create other directory solutions in the root directory (M1 chip is also applicable)
- JQuery determines whether a property has hasattr
- ES6 determines what the string begins with or ends with
- XML tag has empty body less… (Ctrl+F1) Reports empty tag body. The validation works in XML / JSP
- Several methods of deleting all empty lines in text under Linux
- Empty Matrices, Scalars, and Vectors
- error(-215) !empty() in function detectMultiScale solution
- macbook golang zsh: exec format error
- How to empty a whole line in latex (simple and effective)
- Resolve Vue error empty block XXXX
- When installing pyaudio, an error is reported: failed error: portaudio. H: there is no such file or directory