forked from o1egl/paseto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_enum.go
78 lines (64 loc) · 1.55 KB
/
parser_enum.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Code generated by go-enum
// DO NOT EDIT!
package paseto
import (
"fmt"
)
const (
// PurposeLocal is a Purpose of type Local
PurposeLocal Purpose = iota
// PurposePublic is a Purpose of type Public
PurposePublic
)
const _PurposeName = "localpublic"
var _PurposeMap = map[Purpose]string{
0: _PurposeName[0:5],
1: _PurposeName[5:11],
}
// String implements the Stringer interface.
func (x Purpose) String() string {
if str, ok := _PurposeMap[x]; ok {
return str
}
return fmt.Sprintf("Purpose(%d)", x)
}
var _PurposeValue = map[string]Purpose{
_PurposeName[0:5]: 0,
_PurposeName[5:11]: 1,
}
// ParsePurpose attempts to convert a string to a Purpose
func ParsePurpose(name string) (Purpose, error) {
if x, ok := _PurposeValue[name]; ok {
return x, nil
}
return Purpose(0), fmt.Errorf("%s is not a valid Purpose", name)
}
const (
// VersionV1 is a Version of type V1
VersionV1 Version = iota
// VersionV2 is a Version of type V2
VersionV2
)
const _VersionName = "v1v2"
var _VersionMap = map[Version]string{
0: _VersionName[0:2],
1: _VersionName[2:4],
}
// String implements the Stringer interface.
func (x Version) String() string {
if str, ok := _VersionMap[x]; ok {
return str
}
return fmt.Sprintf("Version(%d)", x)
}
var _VersionValue = map[string]Version{
_VersionName[0:2]: 0,
_VersionName[2:4]: 1,
}
// ParseVersion attempts to convert a string to a Version
func ParseVersion(name string) (Version, error) {
if x, ok := _VersionValue[name]; ok {
return x, nil
}
return Version(0), fmt.Errorf("%s is not a valid Version", name)
}