/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
pkg/txt/numeric.go
34 строки
474 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" ) // Numeric removes non-numeric characters from a string and returns the result. func Numeric(s string) string { if s == "" { return "" } sep := '.' if c := strings.Count(s, "."); c == 0 || c > 1 { sep = ',' } // Remove invalid characters. s = strings.Map(func(r rune) rune { switch { case r == sep: return '.' case r == '-': return '-' case r < '0' || r > '9': return -1 } return r }, s) return s }