2022-02-22 13:05:33 +01:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
2022-03-05 18:32:27 +01:00
|
|
|
// Read Méthode permettant de lire le fichier de donfiguration
|
|
|
|
// return AppConfig
|
2022-02-22 13:05:33 +01:00
|
|
|
func Read(filePath string) (*AppConfig, error) {
|
|
|
|
config := AppConfig{}
|
|
|
|
file, err := ioutil.ReadFile(filePath)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
errJson := json.Unmarshal(file, &config)
|
|
|
|
if errJson != nil {
|
|
|
|
return nil, errJson
|
|
|
|
}
|
|
|
|
return &config, nil
|
|
|
|
}
|