improve fileInit func by not loading unspecified data (#189)
* improve fileInit func by not loading unsepcified data
This commit is contained in:
parent
5595070e67
commit
25dfcebf4c
2 changed files with 5 additions and 4 deletions
|
@ -60,12 +60,13 @@ func FileInit(fileFolder string, filename string, fileType string) error {
|
|||
}
|
||||
defer file.Close()
|
||||
|
||||
if fileType == "" {
|
||||
log.Debugf("ignored file %s%s because no type specified", fileFolder, filename)
|
||||
return nil
|
||||
}
|
||||
if _, ok := dataFile[filename]; !ok {
|
||||
dataFile[filename] = []string{}
|
||||
}
|
||||
if fileType == "" {
|
||||
fileType = "string"
|
||||
}
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
if strings.HasPrefix(scanner.Text(), "#") { // allow comments
|
||||
|
|
|
@ -165,7 +165,7 @@ func TestFile(t *testing.T) {
|
|||
log.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
err := FileInit(TestFolder, "test_data.txt", "")
|
||||
err := FileInit(TestFolder, "test_data.txt", "string")
|
||||
if err != nil {
|
||||
log.Fatalf(err.Error())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue