Skip to content

Instantly share code, notes, and snippets.

@bbg
Created February 4, 2020 12:06
Show Gist options
  • Select an option

  • Save bbg/247fbec834acd5e933ccdbd27079deaa to your computer and use it in GitHub Desktop.

Select an option

Save bbg/247fbec834acd5e933ccdbd27079deaa to your computer and use it in GitHub Desktop.
file listing in folder
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
var files []string
root := "/home/puncrash/@Workspace/github.com/gustavocd/file-upload-ajax"
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
files = append(files, path)
return nil
})
if err != nil {
panic(err)
}
for _, file := range files {
fmt.Println(file)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment