Answer the question
In order to leave comments, you need to log in
How to get folder list from folders in go?
package main
import (
"fmt"
"io/ioutil"
"log"
)
func main() {
files, err := ioutil.ReadDir(".")
if err != nil {
log.Fatal(err)
}
for _, file := range files {
fmt.Println(file.Name(), file.IsDir())
if file.IsDir() == true {
files2 := ioutil.ReadDir("./"+file.Name())
for _, file2 := range files2 {
fmt.Println(file2.Name())
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Everything is simpler: you
checked for an error in the line, but
forgot
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question