/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
pkg/txt/names_parser.go
50 строк
877 B
Michael Mayer
Pkg: Apply "golangci-lint" recommendations to txt/... packages #5330
21 ноя 2025, 18:16
21 ноя 2025, 18:16
52ab802
Код
Авторство
О чём код?
package txt import ( "strings" ) // Name represents the components of a full name. type Name struct { Title string Given string Middle string Family string Suffix string Nick string } // ParseName parses a full name and returns the components. func ParseName(full string) Name { name := Name{} name.Parse(full) return name } // Parse tries to parse a full name. func (name *Name) Parse(full string) { if full == "" { return } for _, w := range KeywordsRegexp.FindAllString(full, -1) { w = strings.Trim(w, "- '") if w == "" || len(w) < 2 && IsLatin(w) { continue } l := strings.ToLower(w) switch { case IsNameTitle[l]: name.Title = AppendName(name.Title, w) case IsNameSuffix[l]: name.Suffix = AppendName(name.Suffix, w) case name.Given == "": name.Given = w default: name.Family = AppendName(name.Family, w) } } }