-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethods.go
More file actions
40 lines (33 loc) · 1.27 KB
/
Copy pathmethods.go
File metadata and controls
40 lines (33 loc) · 1.27 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
package slug
// defaultSlug backs the package-level helpers. It is created once and never
// mutated, so the helpers are safe for concurrent use.
var defaultSlug = New()
// Make returns the slug of t using the default configuration (neutral
// transliteration, "-" separator, original letter case preserved).
// It is shorthand for New().Make(t).
func Make(t string) string {
return defaultSlug.Make(t)
}
// Lower is Make with the result lowercased.
func Lower(t string) string {
return defaultSlug.Lower(t)
}
// Upper is Make with the result uppercased.
func Upper(t string) string {
return defaultSlug.Upper(t)
}
// IsValid reports whether t is already a canonical slug under the default
// configuration (see (*Slug).IsValid).
func IsValid(t string) bool {
return defaultSlug.IsValid(t)
}
// MakeUnique returns a slug of t made unique via exists (see
// (*Slug).MakeUnique), using the default configuration.
func MakeUnique(t string, exists func(string) bool) string {
return defaultSlug.MakeUnique(t, exists)
}
// TryMakeUnique returns a unique slug of t and reports success (see
// (*Slug).TryMakeUnique), using the default configuration.
func TryMakeUnique(t string, exists func(string) bool, maxTries int) (string, bool) {
return defaultSlug.TryMakeUnique(t, exists, maxTries)
}