Reads a directory of files into a struct, where each file name is the key and the contents is the value
(dest interface{}, dirPath string, v *StructValidation)
| 990 | |
| 991 | // Reads a directory of files into a struct, where each file name is the key and the contents is the value |
| 992 | func StructFromFiles(dest interface{}, dirPath string, v *StructValidation) []error { |
| 993 | strMap := map[string]string{} |
| 994 | |
| 995 | fileNames, err := files.ListDir(dirPath, true) |
| 996 | if err != nil { |
| 997 | return []error{err} |
| 998 | } |
| 999 | |
| 1000 | for _, fileName := range fileNames { |
| 1001 | fileBytes, err := files.ReadFileBytes(filepath.Join(dirPath, fileName)) |
| 1002 | if err != nil { |
| 1003 | return []error{err} |
| 1004 | } |
| 1005 | strMap[fileName] = strings.TrimSpace(string(fileBytes)) |
| 1006 | } |
| 1007 | |
| 1008 | return StructFromStringMap(dest, strMap, v) |
| 1009 | } |
| 1010 | |
| 1011 | // |
| 1012 | // Environment variable |
nothing calls this directly
no test coverage detected