Victor Lacasse-Beaudoin
17de134f76
Déplacer ListContenu vers data/ Déplacer handlers / et /api vers handlers/handlers.go Déplacer handlers /api/contenu vers handlers/contenu.go
24 lines
444 B
Go
24 lines
444 B
Go
package data
|
|
|
|
import "os"
|
|
|
|
func ListContenu(path string) ([]string, error) {
|
|
var files []string
|
|
f, err_open := os.Open(path)
|
|
defer f.Close()
|
|
|
|
if err_open != nil {
|
|
return nil, err_open
|
|
}
|
|
fileInfo, err_read := f.Readdir(-1)
|
|
if err_read != nil {
|
|
return nil, err_read
|
|
}
|
|
|
|
for _, file := range fileInfo {
|
|
if file.Name() != ".gitkeep" && file.Name() != "messages.txt" {
|
|
files = append(files, file.Name())
|
|
}
|
|
}
|
|
return files, nil
|
|
}
|