How to get list of folders from a folder in go?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
19 views
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()) } } } }


error: .\\dir.go:18:37: multiple-value ioutil.ReadDir() in single-value context
I understand ReadDir can be used only in 1 variable
and how to be, if not samaraditya
by | 19 views

2 Answers

0 like 0 dislike
Everything is simple: you are in the line
files, err := ioutil.ReadDir(".")
has checked for error, and in
files2 := ioutil.ReadDir("./"+file.Name())
forgot
by
0 like 0 dislike
and how to be, if not samaraditya

write in 1S
by

Related questions

0 like 0 dislike
5 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
35,391 users