I have a list. I would like to add to my list only files. I’ trying to add to it so. But I’m getting an error.
first argument to append must be slice; have interface { IsDir() bool; ModTime() time.Time; Mode() _
os.FileMode; Name() string; Size() int64; Sys() interface {} }
package main
import (
"fmt"
"io/ioutil"
)
func main() {
filepath := "target"
files_dirs, err := ioutil.ReadDir(filepath)
if err != nil {
return
}
list := []string{} // I need to add here
for _, x := range files_dirs {
if x.IsDir() == false {
fmt.Println(x.Name())
list = append(x)
}
}
}