当前位置:网站首页>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
边栏推荐
- Machine learning catalog
- Getting started with vcpkg
- Codeworks round 783 (Div. 2) d problem solution
- Installation, use and problem summary of binlog2sql tool
- 考试系统进入试卷优化思路
- 腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
- An idea of rendering pipeline based on FBO
- OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
- Partage de la conception de l'alimentation électrique de commutation et illustration des compétences en conception de l'alimentation électrique
- Class loading process of JVM
猜你喜欢
Oracle configuration st_ geometry
8266 obtain 18b20 temperature
JVM的类加载过程
Intuitive understanding of the essence of two-dimensional rotation
Using Visual Studio code to develop Arduino
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
网络协议之:sctp流控制传输协议
5 minutes to achieve wechat cloud applet payment function (including source code)
Getting started with vcpkg
优先使用组合而不使用继承
随机推荐
An example of using JNI to directly access surface data
腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
SSDB基础
SQL server requires to query the information of all employees with surname 'Wang'
为何PostgreSQL即将超越SQL Server?
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
[报告] Microsoft :Application of deep learning methods in speech enhancement
MySQL practical skills
openlayers 5.0 两种居中方式
[advanced level 11 of C language -- character and string functions and their simulation implementation (2)]
Oracle配置st_geometry
Steps to build a deep learning environment GPU
Machine learning catalog
SSDB基础2
Class loading process of JVM
White screen processing method of fulter startup page
SSDB foundation 2
Application of DCT transform
Common processing of point cloud dataset
C1000k TCP connection upper limit test 1