package server import ( "fmt" "io/ioutil" "net/http" "os" ) func isDir(path string) bool { stat, err := os.Stat(path) return err == nil && stat.IsDir() } func notesDir(path string, w http.ResponseWriter, r *http.Request) { dirs, files := lsDir(path) content := dirs.List() block(content, w) fmt.Fprintln(w, files.List()) } func lsDir(p string) (Paths, Paths) { dirs := newDirs() files := newFiles() found, _ := ioutil.ReadDir(p) for _, f := range found { dirs.Push(p, f) files.Push(p, f) } return Paths(*dirs), Paths(*files) }