update recipe list and disable git pulling
This commit is contained in:
parent
15e74d47e3
commit
fea5f8452a
7 changed files with 171 additions and 133 deletions
|
|
@ -2,6 +2,7 @@ package helpers
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
|
|
@ -29,7 +30,7 @@ func ReadFile(filePath string) (string, error) {
|
|||
return string(file), nil
|
||||
}
|
||||
|
||||
func ReadRecipeFile(countryID, filePath string) *models.Recipe {
|
||||
func ReadRecipeFile(countryID, filePath string) (*models.Recipe, error) {
|
||||
|
||||
if countryID == "thai" {
|
||||
countryID = ""
|
||||
|
|
@ -38,8 +39,7 @@ func ReadRecipeFile(countryID, filePath string) *models.Recipe {
|
|||
file, err := os.Open(path.Join("cofffeemachineConfig", countryID, filePath))
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Error when open file: %s", err)
|
||||
return nil
|
||||
return nil, fmt.Errorf("error when open file: %s", err)
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
|
@ -49,11 +49,10 @@ func ReadRecipeFile(countryID, filePath string) *models.Recipe {
|
|||
err = json.NewDecoder(file).Decode(&data)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Error when decode file: %s", err)
|
||||
return nil
|
||||
return nil, fmt.Errorf("error when decode file: %s", err)
|
||||
}
|
||||
|
||||
return data
|
||||
return data, nil
|
||||
}
|
||||
|
||||
type RecipePath struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue