package story_service import ( "encoding/json" "errors" "os" ) type Story struct { Places []*Place `json:"places"` } type Place struct { Code string `json:"code"` Text string `json:"text"` } type StoryService struct { story *Story } func NewStoryService() (*StoryService, error) { data, err := os.ReadFile("./story/story.json") if err != nil { return nil, err } story := &Story{} if err := json.Unmarshal(data, story); err != nil { return nil, err } return &StoryService{story: story}, nil } func (s *StoryService) GetPlace(code string) (*Place, error) { for _, place := range s.story.Places { if place.Code == code { return place, nil } } return nil, errors.New("place not found") }