当前位置:网站首页>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
边栏推荐
- openlayers 5.0 热力图
- Decompile and get the source code of any wechat applet - just read this (latest)
- Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es
- 開關電源設計分享及電源設計技巧圖解
- Esp01s with Arduino development environment
- Application of DCT transform
- Is it safe to open an account in Bohai futures.
- C1000k TCP connection upper limit test
- FTP、ssh远程访问及控制
- MySQL practical skills
猜你喜欢

An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary

Audio signal processing and coding - 2.5.3 the discrete cosine transform

Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)

Wechat applet part of the mobile phone Preview PDF did not respond

Reflection on the performance of some OpenGL operations in the past

OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!

Esp01s with Arduino development environment

Intuitive understanding of the essence of two-dimensional rotation

binlog2sql 工具安装使用及问题汇总

MySQL syntax collation (3)
随机推荐
JVM的类加载过程
Intuitive understanding of the essence of two-dimensional rotation
MySQL syntax collation (2)
Openlayers draw rectangle
深度学习环境搭建步骤—gpu
SQL server requires to query the information of all employees with surname 'Wang'
数据分析学习目录
@Analysis of conditional on Web Application
Encyclopedia of professional terms and abbreviations in communication engineering
Customize the non slidable viewpage and how to use it
Keysight has chosen what equipment to buy for you
浅谈c语言指针的强制转换
Gossip: on greed
openlayers draw矩形
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
PostgreSQL
MySQL syntax collation (5) -- functions, stored procedures and triggers
Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)
Speculation on the way to realize the smooth drag preview of video editing software
Data analysis learning directory