master
go 24 lines 428 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package naming
4
5 import "strings"
6
7 var sanitizer = strings.NewReplacer(
8 "/", "_",
9 "\\", "_",
10 " ", "_",
11 ":", "_",
12 "*", "_",
13 "?", "_",
14 "\"", "_",
15 "<", "_",
16 ">", "_",
17 "|", "_",
18 )
19
20 // Sanitize returns a stable identifier-safe representation for names that can
21 // flow into IDs, paths, and type identifiers.
22 func Sanitize(name string) string {
23 return sanitizer.Replace(name)
24 }