mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
7f4fb34182
It is better developing vmctl tool in VictoriaMetrics repository, so it could be released together with the rest of vmutils tools such as vmalert, vmagent, vmbackup, vmrestore and vmauth.
22 lines
483 B
Go
22 lines
483 B
Go
package escape
|
|
|
|
import "strings"
|
|
|
|
var (
|
|
escaper = strings.NewReplacer(`,`, `\,`, `"`, `\"`, ` `, `\ `, `=`, `\=`)
|
|
unescaper = strings.NewReplacer(`\,`, `,`, `\"`, `"`, `\ `, ` `, `\=`, `=`)
|
|
)
|
|
|
|
// UnescapeString returns unescaped version of in.
|
|
func UnescapeString(in string) string {
|
|
if strings.IndexByte(in, '\\') == -1 {
|
|
return in
|
|
}
|
|
return unescaper.Replace(in)
|
|
}
|
|
|
|
// String returns the escaped version of in.
|
|
func String(in string) string {
|
|
return escaper.Replace(in)
|
|
}
|