-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.go
More file actions
56 lines (46 loc) · 1.78 KB
/
Copy pathstrings.go
File metadata and controls
56 lines (46 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package fmt
// This file exposes drop-in replacements matching the stdlib "strings" package
// signatures, implemented on top of the existing Convert/Conv chain API.
// It exists so call sites can migrate off "strings" without needing to learn
// the chained API surface, avoiding common mistakes such as
// Convert(s).Contains(x) (Contains/Index/LastIndex are package functions, not methods).
// See docs/API_STRINGS.md for the full equivalence table.
// TrimSpace mirrors strings.TrimSpace.
func TrimSpace(s string) string {
return Convert(s).TrimSpace().String()
}
// TrimPrefix mirrors strings.TrimPrefix.
func TrimPrefix(s, prefix string) string {
return Convert(s).TrimPrefix(prefix).String()
}
// TrimSuffix mirrors strings.TrimSuffix.
func TrimSuffix(s, suffix string) string {
return Convert(s).TrimSuffix(suffix).String()
}
// ToLower mirrors strings.ToLower.
func ToLower(s string) string {
return Convert(s).ToLower().String()
}
// ToUpper mirrors strings.ToUpper.
func ToUpper(s string) string {
return Convert(s).ToUpper().String()
}
// Repeat mirrors strings.Repeat.
func Repeat(s string, count int) string {
return Convert(s).Repeat(count).String()
}
// ReplaceAll mirrors strings.ReplaceAll.
func ReplaceAll(s, old, new string) string {
return Convert(s).Replace(old, new).String()
}
// ReplaceN mirrors strings.Replace(s, old, new, n).
// Named ReplaceN (not Replace) to avoid colliding with Conv.Replace's
// signature, which accepts values of any type instead of only strings.
func ReplaceN(s, old, new string, n int) string {
return Convert(s).Replace(old, new, n).String()
}
// JoinSlice mirrors strings.Join(elems, sep).
// Named JoinSlice (not Join) to avoid colliding with Conv.Join.
func JoinSlice(elems []string, sep string) string {
return Convert(elems).Join(sep).String()
}