7 "golang.org/x/text/cases"
8 "golang.org/x/text/language"
11func Capitalize(text string) string {
12 return cases.Title(language.English, cases.Compact).String(text)
15// NormalizeSpace normalizes whitespace in the given content string.
16// It replaces Windows-style line endings with Unix-style line endings,
17// converts tabs to four spaces, and trims leading and trailing whitespace.
18func NormalizeSpace(content string) string {
19 content = strings.ReplaceAll(content, "\r\n", "\n")
20 content = strings.ReplaceAll(content, "\t", " ")
21 content = strings.TrimSpace(content)
25// IsValidBase64 reports whether s is canonical base64 under standard
26// encoding (RFC 4648). It requires that s round-trips through
27// decode/encode unchanged — rejecting whitespace, missing padding,
28// and other leniencies that DecodeString alone would accept.
29func IsValidBase64(s string) bool {
33 decoded, err := base64.StdEncoding.DecodeString(s)
37 // Round-trip check rejects whitespace, missing padding, and other
38 // leniencies that DecodeString silently accepts.
39 return base64.StdEncoding.EncodeToString(decoded) == s
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list