generated from VLADIMIR/template
update and fix
This commit is contained in:
@@ -2,7 +2,6 @@ package story_service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
@@ -56,14 +55,18 @@ func NewStoryService() (*StoryService, error) {
|
||||
return &StoryService{story: story}, nil
|
||||
}
|
||||
|
||||
func (s *StoryService) GetPlace(code string) (*Place, error) {
|
||||
func (s *StoryService) GetPlace(code string) *Place {
|
||||
code = clearCode(code)
|
||||
for _, place := range s.story.Places {
|
||||
if clearCode(place.Code) == code {
|
||||
return place, nil
|
||||
return place
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("place not found: %s", code)
|
||||
return &Place{
|
||||
Code: code,
|
||||
Name: "Не найдено",
|
||||
Text: "Такой точки не существует.",
|
||||
}
|
||||
}
|
||||
|
||||
func clearCode(code string) string {
|
||||
|
||||
Reference in New Issue
Block a user