-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
executable file
·59 lines (50 loc) · 1.28 KB
/
types.go
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
57
58
59
package gcompress
import (
"github.com/davidforest123/goutil/basic/gerrors"
"strings"
)
type (
Comp string
Level string
Encrypt string
)
var (
allComps []Comp
CompNone = enrollComp("none")
CompZip = enrollComp("zip")
Comp7Z = enrollComp("7z")
CompSnappy = enrollComp("snappy")
CompS2 = enrollComp("s2")
CompGzip = enrollComp("gzip")
CompPgZip = enrollComp("pgzip")
CompZStd = enrollComp("zstd")
CompZLib = enrollComp("zlib")
CompFlate = enrollComp("flate")
allLevels []Level
LevelStore = enrollLevel("store")
LevelDeflate = enrollLevel("deflate")
allEncrypts []Encrypt
EncryptAES128 = enrollEncrypt("aes-128")
EncryptAES192 = enrollEncrypt("aes-192")
EncryptAES256 = enrollEncrypt("aes-256")
)
func enrollComp(algo string) Comp {
allComps = append(allComps, Comp(algo))
return Comp(algo)
}
func ToComp(algo string) (Comp, error) {
for _, v := range allComps {
if string(v) == strings.ToLower(algo) {
return v, nil
}
}
return CompNone, gerrors.New("unrecognized compress algorithm '%s'", algo)
}
func enrollLevel(level string) Level {
allLevels = append(allLevels, Level(level))
return Level(level)
}
func enrollEncrypt(encrypt string) Encrypt {
allEncrypts = append(allEncrypts, Encrypt(encrypt))
return Encrypt(encrypt)
}