mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-07-01 17:01:14 +03:00
feat: add get files on folder func
This commit is contained in:
parent
56e22fae6f
commit
39b93514a8
28
files/get_files_in_folder.go
Normal file
28
files/get_files_in_folder.go
Normal file
@ -0,0 +1,28 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func GetFilesInFolder(folder string) []string {
|
||||
currentPath, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(filepath.Join(currentPath + "/migrations"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var filesNames []string
|
||||
|
||||
for _, file := range files {
|
||||
filesNames = append(filesNames, file.Name())
|
||||
}
|
||||
|
||||
return filesNames
|
||||
}
|
Loading…
Reference in New Issue
Block a user