当前位置:网站首页>Go recursively loops through folders
Go recursively loops through folders
2022-04-23 19:21:00 【Handsome that handsome】
/** dirname Directory name level Hierarchy */
func listFiles(dirName string,level int) {
//level Used to record the current recursive hierarchy , Generate spaces with a sense of hierarchy
s :="|--"
for i:=0;i<level;i++ {
s = "| "+s
}
fileInfos,err := ioutil.ReadDir(dirName)
if err != nil {
log.Fatal(err)
}
for _,fi := range fileInfos{
filename := dirName+"/"+fi.Name()
fmt.Printf("%s%s\n",s,filename)
if fi.IsDir() {
// Recursive call method
listFiles(filename,level+1)
}
}
}
版权声明
本文为[Handsome that handsome]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210557451118.html
边栏推荐
- Data analysis learning directory
- openlayers 5.0 当地图容器大小改变时,重新加载地图
- Esp01s with Arduino development environment
- RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
- Strange passion
- 深度学习——特征工程小总结
- 网络协议之:sctp流控制传输协议
- MySQL syntax collation (3)
- 命令-sudo
- [report] Microsoft: application of deep learning methods in speech enhancement
猜你喜欢
JVM的类加载过程
命令-sudo
2022.04.23 (the best time for lc_714_to buy and sell stocks, including handling charges)
Intuitive understanding of the essence of two-dimensional rotation
Matlab 2019 installation of deep learning toolbox model for googlenet network
2021-2022-2 ACM集训队每周程序设计竞赛(8)题解
ArcMap publishing slicing service
mysql通过binlog恢复或回滚数据
Switching power supply design sharing and power supply design skills diagram
White screen processing method of fulter startup page
随机推荐
MySQL syntax collation (3)
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
SSDB基础3
Is it safe to open an account in Bohai futures.
Is meituan, a profit-making company with zero foundation, hungry? Coupon CPS applet (with source code)
Installation, use and problem summary of binlog2sql tool
First experience of using fluent canvas
Use of fluent custom fonts and pictures
openlayers 5.0 两种居中方式
An example of using JNI to directly access surface data
PostgreSQL
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
Keysight has chosen what equipment to buy for you
[记录]TypeError: this.getOptions is not a function
Strange passion
机器学习目录
C1000k TCP connection upper limit test
[transfer] summary of new features of js-es6 (one picture)
Raspberry pie 18b20 temperature
Speculation on the way to realize the smooth drag preview of video editing software