27 lines
541 B
Go
27 lines
541 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// Load 获取插件目录中的文件信息
|
|
func Load(dir string) ([]string, error) {
|
|
entries, err := os.ReadDir(dir)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("读取目录错误:%w", err)
|
|
}
|
|
files := make([]string, 0, len(entries))
|
|
for _, entry := range entries {
|
|
info, err := entry.Info()
|
|
if err != nil {
|
|
return nil, fmt.Errorf("获取文件信息错误:%w", err)
|
|
}
|
|
if !info.IsDir() {
|
|
files = append(files, fmt.Sprintf("%s/%s", dir, info.Name()))
|
|
}
|
|
}
|
|
|
|
return files, nil
|
|
}
|