22 lines
487 B
Go
22 lines
487 B
Go
package service
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func loadQuizDataConfig() (GetQuizDataResp, error) {
|
|
configPath := "./quiz_config.json"
|
|
data, err := os.ReadFile(configPath)
|
|
if err != nil {
|
|
return GetQuizDataResp{}, fmt.Errorf("failed to read config file %s: %w", configPath, err)
|
|
}
|
|
var config GetQuizDataResp
|
|
if err := json.Unmarshal(data, &config); err != nil {
|
|
return GetQuizDataResp{}, fmt.Errorf("failed to parse config file: %w", err)
|
|
}
|
|
|
|
return config, nil
|
|
}
|