-
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathstringfns.go
More file actions
35 lines (28 loc) · 820 Bytes
/
stringfns.go
File metadata and controls
35 lines (28 loc) · 820 Bytes
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
package stringfns
import (
"crypto/sha256"
"encoding/hex"
"regexp"
"strconv"
)
type Function func(string) (string, error)
var Functions = map[string]Function{
"strconv.Quote": strconv_Quote,
"strconv.Unquote": strconv.Unquote,
"regexp.QuoteMeta": regexp_QuoteMeta,
"crypto/sha256.Sum256": crypto__sha256_Sum256,
"encoding/hex.EncodeToString": encoding__hex_EncodeToString,
}
func strconv_Quote(v string) (string, error) {
return strconv.Quote(v), nil
}
func regexp_QuoteMeta(v string) (string, error) {
return regexp.QuoteMeta(v), nil
}
func crypto__sha256_Sum256(s string) (string, error) {
v := sha256.Sum256([]byte(s))
return string(v[:]), nil
}
func encoding__hex_EncodeToString(s string) (string, error) {
return hex.EncodeToString([]byte(s)), nil
}