generated from VLADIMIR/template
updates
This commit is contained in:
@@ -2,12 +2,29 @@ package story_service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
replaceMap = map[string]string{
|
||||
"a": "а",
|
||||
"e": "е",
|
||||
"o": "о",
|
||||
"c": "с",
|
||||
"p": "р",
|
||||
"x": "х",
|
||||
"y": "у",
|
||||
"k": "к",
|
||||
"m": "м",
|
||||
"t": "т",
|
||||
"h": "н",
|
||||
"b": "в",
|
||||
"u": "и",
|
||||
}
|
||||
)
|
||||
|
||||
type Story struct {
|
||||
Places []*Place `json:"places"`
|
||||
}
|
||||
@@ -46,10 +63,14 @@ func (s *StoryService) GetPlace(code string) (*Place, error) {
|
||||
return place, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.New(fmt.Sprintf("place not found: %s", code))
|
||||
return nil, fmt.Errorf("place not found: %s", code)
|
||||
}
|
||||
|
||||
func clearCode(code string) string {
|
||||
code = strings.ToLower(code)
|
||||
return strings.ReplaceAll(code, "-", "")
|
||||
code = strings.ReplaceAll(code, "-", "")
|
||||
for latin, cyrillic := range replaceMap {
|
||||
code = strings.ReplaceAll(code, latin, cyrillic)
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user