• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Rican7 / define / 4287451017

27 Feb 2023 10:32PM UTC coverage: 36.531% (+0.2%) from 36.364%
4287451017

push

github

GitHub
Merge pull request #33 from Rican7/feature/stricter-linting

198 of 542 relevant lines covered (36.53%)

2.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/source/normalize.go
1
package source
2

3
import (
4
        "strings"
5
        "unicode"
6

7
        "golang.org/x/text/runes"
8
        "golang.org/x/text/transform"
9
        "golang.org/x/text/unicode/norm"
10
)
11

12
// RemoveDiacritics takes a text and returns the same text with any diacritics
13
// removed. If there's an issue with cleaning the string, the original text is
14
// returned unchanged.
15
func RemoveDiacritics(text string) string {
16✔
16
        transformer := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
16✔
17
        normalized, _, err := transform.String(transformer, text)
16✔
18
        if err != nil {
16✔
19
                return text
×
20
        }
×
21

22
        return normalized
16✔
23
}
24

25
// EqualFoldPlain reports whether s and t, interpreted as UTF-8 strings, are
26
// equal under Unicode case-folding AFTER first having each string normalized.
27
func EqualFoldPlain(s, t string) bool {
6✔
28
        return strings.EqualFold(
6✔
29
                RemoveDiacritics(s),
6✔
30
                RemoveDiacritics(t),
6✔
31
        )
6✔
32
}
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc