update recipe list and disable git pulling

This commit is contained in:
Kenta420 2023-10-31 10:30:06 +07:00
parent 15e74d47e3
commit fea5f8452a
7 changed files with 171 additions and 133 deletions

View file

@ -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 {